./0000755000004100000410000000000014203512441011237 5ustar www-datawww-data./NEWS0000644000004100000410000000000014203512426011727 0ustar www-datawww-data./INSTALL0000644000004100000410000002622214203512426012277 0ustar www-datawww-dataInstallation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 6. Often, you can also type `make uninstall' to remove the installed files again. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae" and if that doesn't work, install pre-built binaries of GCC for HP-UX. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *Note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. ./configure.ac0000644000004100000410000001241714203512441013532 0ustar www-datawww-data# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_INIT(bamf, 0.5.7, ubuntu-desktop@lists.ubuntu.com) AC_PREREQ(2.69) AC_SUBST(LIBBAMF_VER, 3) AC_SUBST(LIBBAMF_SONAME, 2:0:0) AC_CONFIG_SRCDIR(src/main.c) AC_CONFIG_HEADERS(config.h) AM_INIT_AUTOMAKE([foreign tar-pax]) AM_SILENT_RULES([yes]) AC_CONFIG_MACRO_DIR([m4]) GNOME_COMMON_INIT AM_MAINTAINER_MODE AC_ISC_POSIX AC_SUBST(ACLOCAL_AMFLAFS, "$ACLOCAL_FLAGS -I m4") PKG_PROG_PKG_CONFIG if test "x$PKG_CONFIG" = "x"; then AC_MSG_ERROR([You need to install pkg-config]); fi LT_INIT([disable-static]) LT_LIB_M # Checks for programs. AC_PROG_CC AM_PROG_CC_C_O AC_PROG_INSTALL AC_HEADER_STDC # # pkg-config # PKG_PROG_PKG_CONFIG # # glib # PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.38.0 gio-2.0 >= 2.30.0 gio-unix-2.0 gobject-2.0 gmodule-2.0) # # gdbus-codegen # AC_PATH_PROG([GDBUS_CODEGEN], [gdbus-codegen]) if test -z "$GDBUS_CODEGEN"; then AC_MSG_ERROR([gdbus-codegen is required but was not found]); fi # # libwnck # PKG_CHECK_MODULES(WNCK, libwnck-3.0 >= 3.4.7) # # libgtop # PKG_CHECK_MODULES(GTOP, libgtop-2.0) # # libsn # PKG_CHECK_MODULES(SN, libstartup-notification-1.0) # # x11 # PKG_CHECK_MODULES(X, x11) # # DbusMenu # AC_ARG_ENABLE([export-actions-menu], AS_HELP_STRING([--enable-export-actions-menu=@<:@no/yes@:>@],[export window actions menus (requires dbusmenu) @<:@default=no@:>@]),, [enable_export_actions_menu=no]) AM_CONDITIONAL([EXPORT_ACTIONS_MENU],[test "x$enable_export_actions_menu" != "xno"]) if test "x$enable_export_actions_menu" = "xyes"; then PKG_CHECK_MODULES(DBUSMENU, [dbusmenu-glib-0.4, dbusmenu-gtk3-0.4]) fi ########################### # GObject Introspection ########################### GOBJECT_INTROSPECTION_CHECK([0.10.2]) ########################### # Vala API Generation ########################### if test "$enable_introspection" = "yes"; then AC_PATH_PROG([VALA_API_GEN], [vapigen]) if test -z "$VALA_API_GEN"; then AC_MSG_ERROR([vapigen is needed to build introspection]) HAVE_INTROSPECTION=0 enable_introspection="no" fi fi ########################### # GTK-DOC ########################### GTK_DOC_CHECK(1.0) ########################### # gtester2xunit checks # ########################### AC_PATH_PROG([PYTHON],[python3]) AC_MSG_CHECKING(for gtester2xunit dependencies) if !($PYTHON -c "from lxml import etree" 2> /dev/null); then AC_MSG_RESULT([no]) AC_MSG_ERROR([You need to install python3-lxml]); fi AC_MSG_RESULT([yes]) ########################### # Headless tests ########################### AC_ARG_ENABLE([headless-tests], AS_HELP_STRING([--enable-headless-tests=@<:@no/yes@:>@],[enable headless test suite (requires Xvfb) @<:@default=no@:>@]),, [enable_headless_tests=no]) AM_CONDITIONAL([ENABLE_HEADLESS_TESTS],[test "x$enable_headless_tests" != "xno"]) if test "x$enable_headless_tests" = "xyes"; then AC_PATH_PROG([XVFB],[Xvfb]) AC_PATH_PROG([DBUS_RUN_SESSION],[dbus-run-session]) if test -z "$XVFB" -o -z "$DBUS_RUN_SESSION"; then AC_MSG_ERROR([Xvfb and dbus-run-session are needed for headless-tests]) fi fi ########################### # gcov coverage reporting ########################### AC_TDD_GCOV AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes]) AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes]) AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes]) AC_SUBST(COVERAGE_CFLAGS) AC_SUBST(COVERAGE_LDFLAGS) # # Gnome/GTK checks # AM_PATH_GTK_3_0 # Compile warnings AC_ARG_ENABLE(compile-warnings, AS_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@], [Turn on compiler warnings]),, [enable_compile_warnings=maximum]) warning_flags= case "$enable_compile_warnings" in no) warning_flags= ;; minimum) warning_flags="-Wall" ;; yes) warning_flags="-wall -Wno-error=deprecated-declarations" ;; maximum|error) warning_flags="-Wall -Wno-error=deprecated-declarations -Wempty-body -Wformat-security -Winit-self -Warray-bounds -Wimplicit-function-declaration" if test "$enable_compile_warnings" = "error" ; then warning_flags="$warning_flags -Werror" fi ;; *) AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings) ;; esac AC_MSG_CHECKING(what warning flags to pass to the C compiler) AC_MSG_RESULT($warning_flags) dnl CFLAGS CFLAGS="$CFLAGS $warning_flags $LIBM" AC_SUBST(BAMFDAEMON_CFLAGS) AC_SUBST(BAMFDAEMON_LIBS) origgiomodulesdir=`pkg-config --variable=giomoduledir gio-2.0` # Make giomodulesdir honour 'prefix', so that distcheck works. giomodulesdir=`echo "$origgiomodulesdir" | sed 's|/usr|${prefix}|'` AC_SUBST(giomodulesdir) AC_OUTPUT([ Makefile lib/libbamf-private/Makefile lib/libbamf/Makefile lib/libbamf/libbamf3.pc src/Makefile tests/Makefile tests/bamfdaemon/Makefile tests/libbamf/Makefile data/Makefile doc/Makefile doc/reference/Makefile doc/reference/libbamf/Makefile ]) cat < $@ # # Clean and dist targets # EXTRA_DIST = $(SOURCES_BUILD) $(RESOURCES_EXPANDED) $(THEME_ICONS_SOURCE) \ $(foreach pkgcfg_file, $(PKG_CONFIG_FILES), $(pkgcfg_file).in) CLEANFILES = $(OUTPUT_FILES) $(pkgconfig_DATA) DISTCLEANFILES = *.pidb MAINTAINERCLEANFILES = Makefile.in ./README0000644000004100000410000000000014203512426012110 0ustar www-datawww-data./plugins/0000755000004100000410000000000014203512426012723 5ustar www-datawww-data./plugins/chromium/0000755000004100000410000000000014203512426014546 5ustar www-datawww-data./plugins/chromium/manifest.json0000644000004100000410000000041714203512426017251 0ustar www-datawww-data{ "name": "Bamf Tab Plugin", "description": "It does stuff", "version": "1", "background_page": "background.html", "permissions": [ "tabs", "http://*/*" ], "plugins": [ { "path": "plugin/npbamf.so", "public": false } ], "default_locale": "en" } ./plugins/chromium/_locales/0000755000004100000410000000000014203512426016327 5ustar www-datawww-data./plugins/chromium/_locales/en/0000755000004100000410000000000014203512426016731 5ustar www-datawww-data./plugins/chromium/_locales/en/messages.json0000644000004100000410000000013314203512426021430 0ustar www-datawww-data{ "tooltip": { "message": "WebNow Favorite", "description": "Tooltip Text" } } ./plugins/chromium/plugin/0000755000004100000410000000000014203512426016044 5ustar www-datawww-data./plugins/chromium/plugin/npbamf.c0000644000004100000410000001236714203512426017464 0ustar www-datawww-data/* ***** BEGIN LICENSE BLOCK ***** * (C)opyright 2008-2009 Aplix Corporation. anselm@aplixcorp.com * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * ***** END LICENSE BLOCK ***** */ #include #include #include #include #include #include #include #include #include #include static NPObject *so = NULL; static NPNetscapeFuncs *npnfuncs = NULL; static NPP inst = NULL; /* NPN */ static void logmsg(const char *msg) { FILE *out = fopen("npsimple.log", "a"); if(out) { fputs(msg, out); fclose(out); } } static bool hasMethod(NPObject* obj, NPIdentifier methodName) { logmsg("npsimple: hasMethod\n"); return true; } static bool invokeAddTab (NPObject *obj, const NPVariant *args, uint32_t argCount, NPVariant *result) { const NPString *id; id = &NPVARIANT_TO_STRING (args[0]); logmsg (id->UTF8Characters); logmsg ("\n"); return true; } static bool invoke(NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result) { int error; char *name; logmsg("npsimple: invoke\n"); error = 1; name = npnfuncs->utf8fromidentifier(methodName); if(name && !strcmp (name, "addTab")) { logmsg("npsimple: invoke addTab\n"); return invokeAddTab(obj, args, argCount, result); } npnfuncs->setexception(obj, "exception during invocation"); return false; } static bool hasProperty(NPObject *obj, NPIdentifier propertyName) { logmsg("npsimple: hasProperty\n"); return false; } static bool getProperty(NPObject *obj, NPIdentifier propertyName, NPVariant *result) { logmsg("npsimple: getProperty\n"); return false; } static NPClass npcRefObject = { NP_CLASS_STRUCT_VERSION, NULL, NULL, NULL, hasMethod, invoke, invokeAddTab, hasProperty, getProperty, NULL, NULL, }; /* NPP */ static NPError nevv(NPMIMEType pluginType, NPP instance, short mode, short argc, char *argn[], char *argv[], NPSavedData *saved) { inst = instance; logmsg("npsimple: new\n"); return NPERR_NO_ERROR; } static NPError destroy(NPP instance, NPSavedData **save) { if(so) npnfuncs->releaseobject(so); so = NULL; logmsg("npsimple: destroy\n"); return NPERR_NO_ERROR; } static NPError getValue(NPP instance, NPPVariable variable, void *value) { inst = instance; switch(variable) { default: logmsg("npsimple: getvalue - default\n"); return NPERR_GENERIC_ERROR; case NPPVpluginNameString: logmsg("npsimple: getvalue - name string\n"); *((char **)value) = "WebFavPlugin"; break; case NPPVpluginDescriptionString: logmsg("npsimple: getvalue - description string\n"); *((char **)value) = "Canonical WebFav plugin."; break; case NPPVpluginScriptableNPObject: logmsg("npsimple: getvalue - scriptable object\n"); if(!so) so = npnfuncs->createobject(instance, &npcRefObject); npnfuncs->retainobject(so); *(NPObject **)value = so; break; case NPPVpluginNeedsXEmbed: logmsg("npsimple: getvalue - xembed\n"); *((PRBool *)value) = PR_TRUE; /* for some reason returning false here results in the plugin getting shut down */ break; } return NPERR_NO_ERROR; } static NPError /* expected by Safari on Darwin */ handleEvent(NPP instance, void *ev) { inst = instance; logmsg("npsimple: handleEvent\n"); return NPERR_NO_ERROR; } static NPError /* expected by Opera */ setWindow(NPP instance, NPWindow* pNPWindow) { inst = instance; logmsg("npsimple: setWindow\n"); return NPERR_NO_ERROR; } /* EXPORT */ #ifdef __cplusplus extern "C" { #endif NPError OSCALL NP_GetEntryPoints(NPPluginFuncs *nppfuncs) { logmsg("npsimple: NP_GetEntryPoints\n"); nppfuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; nppfuncs->newp = nevv; nppfuncs->destroy = destroy; nppfuncs->getvalue = getValue; nppfuncs->event = handleEvent; nppfuncs->setwindow = setWindow; return NPERR_NO_ERROR; } #ifndef HIBYTE #define HIBYTE(x) ((((uint32)(x)) & 0xff00) >> 8) #endif NPError OSCALL NP_Initialize(NPNetscapeFuncs *npnf, NPPluginFuncs *nppfuncs) { logmsg("npsimple: NP_Initialize\n"); if(npnf == NULL) return NPERR_INVALID_FUNCTABLE_ERROR; if(HIBYTE(npnf->version) > NP_VERSION_MAJOR) return NPERR_INCOMPATIBLE_VERSION_ERROR; npnfuncs = npnf; NP_GetEntryPoints(nppfuncs); return NPERR_NO_ERROR; } NPError OSCALL NP_Shutdown() { logmsg("npsimple: NP_Shutdown\n"); return NPERR_NO_ERROR; } char * NP_GetMIMEDescription(void) { logmsg("npsimple: NP_GetMIMEDescription\n"); return "application/x-canonical-webfav:webfav:Canonical WebFav"; } NPError OSCALL /* needs to be present for WebKit based browsers */ NP_GetValue(void *npp, NPPVariable variable, void *value) { inst = (NPP)npp; return getValue((NPP)npp, variable, value); } #ifdef __cplusplus } #endif ./plugins/chromium/plugin/config.mk0000644000004100000410000000037314203512426017645 0ustar www-datawww-dataVERSION = 0.3 # Customize below to fit your system INCS = `pkg-config --libs --cflags libxul nspr libbamf` CPPFLAGS = -DVERSION=\"${VERSION}\" -DXULRUNNER_SDK CFLAGS = -g -pedantic -fPIC -Wall -O2 ${INCS} ${CPPFLAGS} # compiler and linker CC = gcc ./plugins/chromium/plugin/npupp.h0000644000004100000410000006421614203512426017370 0ustar www-datawww-data/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ /* * npupp.h $Revision: 3.26 $ * function call mecahnics needed by platform specific glue code. */ #ifndef _NPUPP_H_ #define _NPUPP_H_ #if defined(__OS2__) #pragma pack(1) #endif #ifndef GENERATINGCFM #define GENERATINGCFM 0 #endif #ifndef _NPAPI_H_ #ifdef __native_client__ #include #else #include "third_party/npapi/bindings/npapi.h" #endif #endif #ifdef __native_client__ #include #else #include "third_party/npapi/bindings/npruntime.h" #endif /****************************************************************************************** plug-in function table macros for each function in and out of the plugin API we define typedef NPP_FooUPP #define NewNPP_FooProc #define CallNPP_FooProc *******************************************************************************************/ /* NPP_Initialize */ typedef void (* NP_LOADDS NPP_InitializeUPP)(void); #define NewNPP_InitializeProc(FUNC) \ ((NPP_InitializeUPP) (FUNC)) #define CallNPP_InitializeProc(FUNC) \ (*(FUNC))() /* NPP_Shutdown */ typedef void (* NP_LOADDS NPP_ShutdownUPP)(void); #define NewNPP_ShutdownProc(FUNC) \ ((NPP_ShutdownUPP) (FUNC)) #define CallNPP_ShutdownProc(FUNC) \ (*(FUNC))() /* NPP_New */ typedef NPError (* NP_LOADDS NPP_NewUPP)(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved); #define NewNPP_NewProc(FUNC) \ ((NPP_NewUPP) (FUNC)) #define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7)) /* NPP_Destroy */ typedef NPError (* NP_LOADDS NPP_DestroyUPP)(NPP instance, NPSavedData** save); #define NewNPP_DestroyProc(FUNC) \ ((NPP_DestroyUPP) (FUNC)) #define CallNPP_DestroyProc(FUNC, ARG1, ARG2) \ (*(FUNC))((ARG1), (ARG2)) /* NPP_SetWindow */ typedef NPError (* NP_LOADDS NPP_SetWindowUPP)(NPP instance, NPWindow* window); #define NewNPP_SetWindowProc(FUNC) \ ((NPP_SetWindowUPP) (FUNC)) #define CallNPP_SetWindowProc(FUNC, ARG1, ARG2) \ (*(FUNC))((ARG1), (ARG2)) /* NPP_NewStream */ typedef NPError (* NP_LOADDS NPP_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype); #define NewNPP_NewStreamProc(FUNC) \ ((NPP_NewStreamUPP) (FUNC)) #define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5)) /* NPP_DestroyStream */ typedef NPError (* NP_LOADDS NPP_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason); #define NewNPP_DestroyStreamProc(FUNC) \ ((NPP_DestroyStreamUPP) (FUNC)) #define CallNPP_DestroyStreamProc(FUNC, NPParg, NPStreamPtr, NPReasonArg) \ (*(FUNC))((NPParg), (NPStreamPtr), (NPReasonArg)) /* NPP_WriteReady */ typedef int32_t (* NP_LOADDS NPP_WriteReadyUPP)(NPP instance, NPStream* stream); #define NewNPP_WriteReadyProc(FUNC) \ ((NPP_WriteReadyUPP) (FUNC)) #define CallNPP_WriteReadyProc(FUNC, NPParg, NPStreamPtr) \ (*(FUNC))((NPParg), (NPStreamPtr)) /* NPP_Write */ typedef int32_t (* NP_LOADDS NPP_WriteUPP)(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer); #define NewNPP_WriteProc(FUNC) \ ((NPP_WriteUPP) (FUNC)) #define CallNPP_WriteProc(FUNC, NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr) \ (*(FUNC))((NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr)) /* NPP_StreamAsFile */ typedef void (* NP_LOADDS NPP_StreamAsFileUPP)(NPP instance, NPStream* stream, const char* fname); #define NewNPP_StreamAsFileProc(FUNC) \ ((NPP_StreamAsFileUPP) (FUNC)) #define CallNPP_StreamAsFileProc(FUNC, ARG1, ARG2, ARG3) \ (*(FUNC))((ARG1), (ARG2), (ARG3)) /* NPP_Print */ typedef void (* NP_LOADDS NPP_PrintUPP)(NPP instance, NPPrint* platformPrint); #define NewNPP_PrintProc(FUNC) \ ((NPP_PrintUPP) (FUNC)) #define CallNPP_PrintProc(FUNC, NPParg, NPPrintArg) \ (*(FUNC))((NPParg), (NPPrintArg)) /* NPP_HandleEvent */ typedef int16_t (* NP_LOADDS NPP_HandleEventUPP)(NPP instance, void* event); #define NewNPP_HandleEventProc(FUNC) \ ((NPP_HandleEventUPP) (FUNC)) #define CallNPP_HandleEventProc(FUNC, NPParg, voidPtr) \ (*(FUNC))((NPParg), (voidPtr)) /* NPP_URLNotify */ typedef void (* NP_LOADDS NPP_URLNotifyUPP)(NPP instance, const char* url, NPReason reason, void* notifyData); #define NewNPP_URLNotifyProc(FUNC) \ ((NPP_URLNotifyUPP) (FUNC)) #define CallNPP_URLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) /* NPP_GetValue */ typedef NPError (* NP_LOADDS NPP_GetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue); #define NewNPP_GetValueProc(FUNC) \ ((NPP_GetValueUPP) (FUNC)) #define CallNPP_GetValueProc(FUNC, ARG1, ARG2, ARG3) \ (*(FUNC))((ARG1), (ARG2), (ARG3)) /* NPP_SetValue */ typedef NPError (* NP_LOADDS NPP_SetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue); #define NewNPP_SetValueProc(FUNC) \ ((NPP_SetValueUPP) (FUNC)) #define CallNPP_SetValueProc(FUNC, ARG1, ARG2, ARG3) \ (*(FUNC))((ARG1), (ARG2), (ARG3)) /* * Netscape entry points */ /* NPN_GetValue */ typedef NPError (* NP_LOADDS NPN_GetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue); #define NewNPN_GetValueProc(FUNC) \ ((NPN_GetValueUPP) (FUNC)) #define CallNPN_GetValueProc(FUNC, ARG1, ARG2, ARG3) \ (*(FUNC))((ARG1), (ARG2), (ARG3)) /* NPN_SetValue */ typedef NPError (* NP_LOADDS NPN_SetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue); #define NewNPN_SetValueProc(FUNC) \ ((NPN_SetValueUPP) (FUNC)) #define CallNPN_SetValueProc(FUNC, ARG1, ARG2, ARG3) \ (*(FUNC))((ARG1), (ARG2), (ARG3)) /* NPN_GetUrlNotify */ typedef NPError (* NP_LOADDS NPN_GetURLNotifyUPP)(NPP instance, const char* url, const char* window, void* notifyData); #define NewNPN_GetURLNotifyProc(FUNC) \ ((NPN_GetURLNotifyUPP) (FUNC)) #define CallNPN_GetURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) /* NPN_PostUrlNotify */ typedef NPError (* NP_LOADDS NPN_PostURLNotifyUPP)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData); #define NewNPN_PostURLNotifyProc(FUNC) \ ((NPN_PostURLNotifyUPP) (FUNC)) #define CallNPN_PostURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7)) /* NPN_GetUrl */ typedef NPError (* NP_LOADDS NPN_GetURLUPP)(NPP instance, const char* url, const char* window); #define NewNPN_GetURLProc(FUNC) \ ((NPN_GetURLUPP) (FUNC)) #define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3) \ (*(FUNC))((ARG1), (ARG2), (ARG3)) /* NPN_PostUrl */ typedef NPError (* NP_LOADDS NPN_PostURLUPP)(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file); #define NewNPN_PostURLProc(FUNC) \ ((NPN_PostURLUPP) (FUNC)) #define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6)) /* NPN_RequestRead */ typedef NPError (* NP_LOADDS NPN_RequestReadUPP)(NPStream* stream, NPByteRange* rangeList); #define NewNPN_RequestReadProc(FUNC) \ ((NPN_RequestReadUPP) (FUNC)) #define CallNPN_RequestReadProc(FUNC, stream, range) \ (*(FUNC))((stream), (range)) /* NPN_NewStream */ typedef NPError (* NP_LOADDS NPN_NewStreamUPP)(NPP instance, NPMIMEType type, const char* window, NPStream** stream); #define NewNPN_NewStreamProc(FUNC) \ ((NPN_NewStreamUPP) (FUNC)) #define CallNPN_NewStreamProc(FUNC, npp, type, window, stream) \ (*(FUNC))((npp), (type), (window), (stream)) /* NPN_Write */ typedef int32_t (* NP_LOADDS NPN_WriteUPP)(NPP instance, NPStream* stream, int32_t len, void* buffer); #define NewNPN_WriteProc(FUNC) \ ((NPN_WriteUPP) (FUNC)) #define CallNPN_WriteProc(FUNC, npp, stream, len, buffer) \ (*(FUNC))((npp), (stream), (len), (buffer)) /* NPN_DestroyStream */ typedef NPError (* NP_LOADDS NPN_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason); #define NewNPN_DestroyStreamProc(FUNC) \ ((NPN_DestroyStreamUPP) (FUNC)) #define CallNPN_DestroyStreamProc(FUNC, npp, stream, reason) \ (*(FUNC))((npp), (stream), (reason)) /* NPN_Status */ typedef void (* NP_LOADDS NPN_StatusUPP)(NPP instance, const char* message); #define NewNPN_StatusProc(FUNC) \ ((NPN_StatusUPP) (FUNC)) #define CallNPN_StatusProc(FUNC, npp, msg) \ (*(FUNC))((npp), (msg)) /* NPN_UserAgent */ typedef const char* (* NP_LOADDS NPN_UserAgentUPP)(NPP instance); #define NewNPN_UserAgentProc(FUNC) \ ((NPN_UserAgentUPP) (FUNC)) #define CallNPN_UserAgentProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_MemAlloc */ typedef void* (* NP_LOADDS NPN_MemAllocUPP)(uint32_t size); #define NewNPN_MemAllocProc(FUNC) \ ((NPN_MemAllocUPP) (FUNC)) #define CallNPN_MemAllocProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN__MemFree */ typedef void (* NP_LOADDS NPN_MemFreeUPP)(void* ptr); #define NewNPN_MemFreeProc(FUNC) \ ((NPN_MemFreeUPP) (FUNC)) #define CallNPN_MemFreeProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_MemFlush */ typedef uint32_t (* NP_LOADDS NPN_MemFlushUPP)(uint32_t size); #define NewNPN_MemFlushProc(FUNC) \ ((NPN_MemFlushUPP) (FUNC)) #define CallNPN_MemFlushProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_ReloadPlugins */ typedef void (* NP_LOADDS NPN_ReloadPluginsUPP)(NPBool reloadPages); #define NewNPN_ReloadPluginsProc(FUNC) \ ((NPN_ReloadPluginsUPP) (FUNC)) #define CallNPN_ReloadPluginsProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_GetJavaEnv */ // The return type of this used to be JRIEnv*. Use void* now to // maintain binary compatibility but eliminate the dependency on Java // types. typedef void* (* NP_LOADDS NPN_GetJavaEnvUPP)(void); #define NewNPN_GetJavaEnvProc(FUNC) \ ((NPN_GetJavaEnvUPP) (FUNC)) #define CallNPN_GetJavaEnvProc(FUNC) \ (*(FUNC))() /* NPN_GetJavaPeer */ // The return type of this used to be jref, which was a pointer to a // Java thing. Use void* now to maintain binary compatibility but // eliminate the dependency on Java types. typedef void* (* NP_LOADDS NPN_GetJavaPeerUPP)(NPP instance); #define NewNPN_GetJavaPeerProc(FUNC) \ ((NPN_GetJavaPeerUPP) (FUNC)) #define CallNPN_GetJavaPeerProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_InvalidateRect */ typedef void (* NP_LOADDS NPN_InvalidateRectUPP)(NPP instance, NPRect *rect); #define NewNPN_InvalidateRectProc(FUNC) \ ((NPN_InvalidateRectUPP) (FUNC)) #define CallNPN_InvalidateRectProc(FUNC, ARG1, ARG2) \ (*(FUNC))((ARG1), (ARG2)) /* NPN_InvalidateRegion */ typedef void (* NP_LOADDS NPN_InvalidateRegionUPP)(NPP instance, NPRegion region); #define NewNPN_InvalidateRegionProc(FUNC) \ ((NPN_InvalidateRegionUPP) (FUNC)) #define CallNPN_InvalidateRegionProc(FUNC, ARG1, ARG2) \ (*(FUNC))((ARG1), (ARG2)) /* NPN_ForceRedraw */ typedef void (* NP_LOADDS NPN_ForceRedrawUPP)(NPP instance); #define NewNPN_ForceRedrawProc(FUNC) \ ((NPN_ForceRedrawUPP) (FUNC)) #define CallNPN_ForceRedrawProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_GetStringIdentifier */ typedef NPIdentifier (* NP_LOADDS NPN_GetStringIdentifierUPP)(const NPUTF8* name); #define NewNPN_GetStringIdentifierProc(FUNC) \ ((NPN_GetStringIdentifierUPP) (FUNC)) #define CallNPN_GetStringIdentifierProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_GetStringIdentifiers */ typedef void (* NP_LOADDS NPN_GetStringIdentifiersUPP)(const NPUTF8** names, int32_t nameCount, NPIdentifier* identifiers); #define NewNPN_GetStringIdentifiersProc(FUNC) \ ((NPN_GetStringIdentifiersUPP) (FUNC)) #define CallNPN_GetStringIdentifiersProc(FUNC, ARG1, ARG2, ARG3) \ (*(FUNC))((ARG1), (ARG2), (ARG3)) /* NPN_GetIntIdentifier */ typedef NPIdentifier (* NP_LOADDS NPN_GetIntIdentifierUPP)(int32_t intid); #define NewNPN_GetIntIdentifierProc(FUNC) \ ((NPN_GetIntIdentifierUPP) (FUNC)) #define CallNPN_GetIntIdentifierProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_IdentifierIsString */ typedef bool (* NP_LOADDS NPN_IdentifierIsStringUPP)(NPIdentifier identifier); #define NewNPN_IdentifierIsStringProc(FUNC) \ ((NPN_IdentifierIsStringUPP) (FUNC)) #define CallNPN_IdentifierIsStringProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_UTF8FromIdentifier */ typedef NPUTF8* (* NP_LOADDS NPN_UTF8FromIdentifierUPP)(NPIdentifier identifier); #define NewNPN_UTF8FromIdentifierProc(FUNC) \ ((NPN_UTF8FromIdentifierUPP) (FUNC)) #define CallNPN_UTF8FromIdentifierProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_IntFromIdentifier */ typedef int32_t (* NP_LOADDS NPN_IntFromIdentifierUPP)(NPIdentifier identifier); #define NewNPN_IntFromIdentifierProc(FUNC) \ ((NPN_IntFromIdentifierUPP) (FUNC)) #define CallNPN_IntFromIdentifierProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_CreateObject */ typedef NPObject* (* NP_LOADDS NPN_CreateObjectUPP)(NPP npp, NPClass *aClass); #define NewNPN_CreateObjectProc(FUNC) \ ((NPN_CreateObjectUPP) (FUNC)) #define CallNPN_CreateObjectProc(FUNC, ARG1, ARG2) \ (*(FUNC))((ARG1), (ARG2)) /* NPN_RetainObject */ typedef NPObject* (* NP_LOADDS NPN_RetainObjectUPP)(NPObject *obj); #define NewNPN_RetainObjectProc(FUNC) \ ((NPN_RetainObjectUPP) (FUNC)) #define CallNPN_RetainObjectProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_ReleaseObject */ typedef void (* NP_LOADDS NPN_ReleaseObjectUPP)(NPObject *obj); #define NewNPN_ReleaseObjectProc(FUNC) \ ((NPN_ReleaseObjectUPP) (FUNC)) #define CallNPN_ReleaseObjectProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_Invoke */ typedef bool (* NP_LOADDS NPN_InvokeUPP)(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result); #define NewNPN_InvokeProc(FUNC) \ ((NPN_InvokeUPP) (FUNC)) #define CallNPN_InvokeProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6)) /* NPN_InvokeDefault */ typedef bool (* NP_LOADDS NPN_InvokeDefaultUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); #define NewNPN_InvokeDefaultProc(FUNC) \ ((NPN_InvokeDefaultUPP) (FUNC)) #define CallNPN_InvokeDefaultProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5)) /* NPN_Evaluate */ typedef bool (* NP_LOADDS NPN_EvaluateUPP)(NPP npp, NPObject *obj, NPString *script, NPVariant *result); #define NewNPN_EvaluateProc(FUNC) \ ((NPN_EvaluateUPP) (FUNC)) #define CallNPN_EvaluateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) /* NPN_GetProperty */ typedef bool (* NP_LOADDS NPN_GetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result); #define NewNPN_GetPropertyProc(FUNC) \ ((NPN_GetPropertyUPP) (FUNC)) #define CallNPN_GetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) /* NPN_SetProperty */ typedef bool (* NP_LOADDS NPN_SetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value); #define NewNPN_SetPropertyProc(FUNC) \ ((NPN_SetPropertyUPP) (FUNC)) #define CallNPN_SetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) /* NPN_RemoveProperty */ typedef bool (* NP_LOADDS NPN_RemovePropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName); #define NewNPN_RemovePropertyProc(FUNC) \ ((NPN_RemovePropertyUPP) (FUNC)) #define CallNPN_RemovePropertyProc(FUNC, ARG1, ARG2, ARG3) \ (*(FUNC))((ARG1), (ARG2), (ARG3)) /* NPN_HasProperty */ typedef bool (* NP_LOADDS NPN_HasPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName); #define NewNPN_HasPropertyProc(FUNC) \ ((NPN_HasPropertyUPP) (FUNC)) #define CallNPN_HasPropertyProc(FUNC, ARG1, ARG2, ARG3) \ (*(FUNC))((ARG1), (ARG2), (ARG3)) /* NPN_HasMethod */ typedef bool (* NP_LOADDS NPN_HasMethodUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName); #define NewNPN_HasMethodProc(FUNC) \ ((NPN_HasMethodUPP) (FUNC)) #define CallNPN_HasMethodProc(FUNC, ARG1, ARG2, ARG3) \ (*(FUNC))((ARG1), (ARG2), (ARG3)) /* NPN_ReleaseVariantValue */ typedef void (* NP_LOADDS NPN_ReleaseVariantValueUPP)(NPVariant *variant); #define NewNPN_ReleaseVariantValueProc(FUNC) \ ((NPN_ReleaseVariantValueUPP) (FUNC)) #define CallNPN_ReleaseVariantValueProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_SetException */ typedef void (* NP_LOADDS NPN_SetExceptionUPP)(NPObject *obj, const NPUTF8 *message); #define NewNPN_SetExceptionProc(FUNC) \ ((NPN_SetExceptionUPP) (FUNC)) #define CallNPN_SetExceptionProc(FUNC, ARG1, ARG2) \ (*(FUNC))((ARG1), (ARG2)) /* NPN_PushPopupsEnabledStateUPP */ typedef void (* NP_LOADDS NPN_PushPopupsEnabledStateUPP)(NPP npp, NPBool enabled); #define NewNPN_PushPopupsEnabledStateProc(FUNC) \ ((NPN_PushPopupsEnabledStateUPP) (FUNC)) #define CallNPN_PushPopupsEnabledStateProc(FUNC, ARG1, ARG2) \ (*(FUNC))((ARG1), (ARG2)) /* NPN_PopPopupsEnabledState */ typedef void (* NP_LOADDS NPN_PopPopupsEnabledStateUPP)(NPP npp); #define NewNPN_PopPopupsEnabledStateProc(FUNC) \ ((NPN_PopPopupsEnabledStateUPP) (FUNC)) #define CallNPN_PopPopupsEnabledStateProc(FUNC, ARG1) \ (*(FUNC))((ARG1)) /* NPN_Enumerate */ typedef bool (* NP_LOADDS NPN_EnumerateUPP)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count); #define NewNPN_EnumerateProc(FUNC) \ ((NPN_EnumerateUPP) (FUNC)) #define CallNPN_EnumerateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) /* NPN_PluginThreadAsyncCall */ typedef void (* NP_LOADDS NPN_PluginThreadAsyncCallUPP)(NPP instance, void (*func)(void *), void *userData); #define NewNPN_PluginThreadAsyncCallProc(FUNC) \ ((NPN_PluginThreadAsyncCallUPP) (FUNC)) #define CallNPN_PluginThreadAsyncCallProc(FUNC, ARG1, ARG2, ARG3) \ (*(FUNC))((ARG1), (ARG2), (ARG3)) /* NPN_Construct */ typedef bool (* NP_LOADDS NPN_ConstructUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); #define NewNPN_ConstructProc(FUNC) \ ((NPN_ConstructUPP) (FUNC)) #define CallNPN_ConstructProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \ (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5)) /****************************************************************************************** * The actual plugin function table definitions *******************************************************************************************/ typedef struct _NPPluginFuncs { uint16_t size; uint16_t version; NPP_NewUPP newp; NPP_DestroyUPP destroy; NPP_SetWindowUPP setwindow; NPP_NewStreamUPP newstream; NPP_DestroyStreamUPP destroystream; NPP_StreamAsFileUPP asfile; NPP_WriteReadyUPP writeready; NPP_WriteUPP write; NPP_PrintUPP print; NPP_HandleEventUPP event; NPP_URLNotifyUPP urlnotify; // The type of this used to be JRIGlobalRef, which was a void *. // Use void * here directly now that we don't expose any Java // specific things in the plugin API. void* javaClass; NPP_GetValueUPP getvalue; NPP_SetValueUPP setvalue; } NPPluginFuncs; typedef struct _NPNetscapeFuncs { uint16_t size; uint16_t version; NPN_GetURLUPP geturl; NPN_PostURLUPP posturl; NPN_RequestReadUPP requestread; NPN_NewStreamUPP newstream; NPN_WriteUPP write; NPN_DestroyStreamUPP destroystream; NPN_StatusUPP status; NPN_UserAgentUPP uagent; NPN_MemAllocUPP memalloc; NPN_MemFreeUPP memfree; NPN_MemFlushUPP memflush; NPN_ReloadPluginsUPP reloadplugins; NPN_GetJavaEnvUPP getJavaEnv; NPN_GetJavaPeerUPP getJavaPeer; NPN_GetURLNotifyUPP geturlnotify; NPN_PostURLNotifyUPP posturlnotify; NPN_GetValueUPP getvalue; NPN_SetValueUPP setvalue; NPN_InvalidateRectUPP invalidaterect; NPN_InvalidateRegionUPP invalidateregion; NPN_ForceRedrawUPP forceredraw; NPN_GetStringIdentifierUPP getstringidentifier; NPN_GetStringIdentifiersUPP getstringidentifiers; NPN_GetIntIdentifierUPP getintidentifier; NPN_IdentifierIsStringUPP identifierisstring; NPN_UTF8FromIdentifierUPP utf8fromidentifier; NPN_IntFromIdentifierUPP intfromidentifier; NPN_CreateObjectUPP createobject; NPN_RetainObjectUPP retainobject; NPN_ReleaseObjectUPP releaseobject; NPN_InvokeUPP invoke; NPN_InvokeDefaultUPP invokeDefault; NPN_EvaluateUPP evaluate; NPN_GetPropertyUPP getproperty; NPN_SetPropertyUPP setproperty; NPN_RemovePropertyUPP removeproperty; NPN_HasPropertyUPP hasproperty; NPN_HasMethodUPP hasmethod; NPN_ReleaseVariantValueUPP releasevariantvalue; NPN_SetExceptionUPP setexception; NPN_PushPopupsEnabledStateUPP pushpopupsenabledstate; NPN_PopPopupsEnabledStateUPP poppopupsenabledstate; NPN_EnumerateUPP enumerate; NPN_PluginThreadAsyncCallUPP pluginthreadasynccall; NPN_ConstructUPP construct; } NPNetscapeFuncs; #ifdef XP_MACOSX /****************************************************************************************** * Mac platform-specific plugin glue stuff *******************************************************************************************/ /* * Main entry point of the plugin. * This routine will be called when the plugin is loaded. The function * tables are passed in and the plugin fills in the NPPluginFuncs table * and NPPShutdownUPP for Netscape's use. */ typedef NPError (* NP_LOADDS NPP_MainEntryUPP)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownUPP*); #define NewNPP_MainEntryProc(FUNC) \ ((NPP_MainEntryUPP) (FUNC)) #define CallNPP_MainEntryProc(FUNC, netscapeFunc, pluginFunc, shutdownUPP) \ (*(FUNC))((netscapeFunc), (pluginFunc), (shutdownUPP)) /* * Mac OS X version(s) of NP_GetMIMEDescription(const char *) * These can be called to retreive MIME information from the plugin dynamically * * Note: For compatibility with Quicktime, BPSupportedMIMEtypes is another way * to get mime info from the plugin only on OSX and may not be supported * in furture version -- use NP_GetMIMEDescription instead */ enum { kBPSupportedMIMETypesStructVers_1 = 1 }; typedef struct _BPSupportedMIMETypes { SInt32 structVersion; /* struct version */ Handle typeStrings; /* STR# formated handle, allocated by plug-in */ Handle infoStrings; /* STR# formated handle, allocated by plug-in */ } BPSupportedMIMETypes; OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags); /* NP_GetMIMEDescription */ #define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription" typedef const char* (* NP_LOADDS NP_GetMIMEDescriptionUPP)(); #define NewNP_GetMIMEDescEntryProc(FUNC) \ ((NP_GetMIMEDescriptionUPP) (FUNC)) #define CallNP_GetMIMEDescEntryProc(FUNC) \ (*(FUNC))() /* BP_GetSupportedMIMETypes */ typedef OSErr (* NP_LOADDS BP_GetSupportedMIMETypesUPP)(BPSupportedMIMETypes*, UInt32); #define NewBP_GetSupportedMIMETypesEntryProc(FUNC) \ ((BP_GetSupportedMIMETypesUPP) (FUNC)) #define CallBP_GetMIMEDescEntryProc(FUNC, mimeInfo, flags) \ (*(FUNC))((mimeInfo), (flags)) #endif /* XP_MACOSX */ #if defined(_WINDOWS) #define OSCALL WINAPI #else #if defined(__OS2__) #define OSCALL _System #else #define OSCALL #endif #endif #if defined(XP_UNIX) /* GCC 3.3 and later support the visibility attribute. */ #if defined(__GNUC__) && \ ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) #define NP_VISIBILITY_DEFAULT __attribute__((visibility("default"))) #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) #define NP_VISIBILITY_DEFAULT __global #else #define NP_VISIBILITY_DEFAULT #endif #define NP_EXPORT(__type) NP_VISIBILITY_DEFAULT __type #endif #if defined( _WINDOWS ) || defined (__OS2__) #ifdef __cplusplus extern "C" { #endif /* plugin meta member functions */ #if defined(__OS2__) typedef struct _NPPluginData { /* Alternate OS2 Plugin interface */ char *pMimeTypes; char *pFileExtents; char *pFileOpenTemplate; char *pProductName; char *pProductDescription; unsigned long dwProductVersionMS; unsigned long dwProductVersionLS; } NPPluginData; NPError OSCALL NP_GetPluginData(NPPluginData * pPluginData); #endif NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs); NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs); NPError OSCALL NP_Shutdown(); char* NP_GetMIMEDescription(); #ifdef __cplusplus } #endif #endif /* _WINDOWS || __OS2__ */ #if defined(__OS2__) #pragma pack() #endif #ifdef XP_UNIX #ifdef __cplusplus extern "C" { #endif /* plugin meta member functions */ NP_EXPORT(char*) NP_GetPluginVersion(void); NP_EXPORT(char*) NP_GetMIMEDescription(void); NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs*, NPPluginFuncs*); NP_EXPORT(NPError) NP_Shutdown(void); NP_EXPORT(NPError) NP_GetValue(void *future, NPPVariable aVariable, void *aValue); #ifdef __cplusplus } #endif #endif /* XP_UNIX */ #endif /* _NPUPP_H_ */ ./plugins/chromium/background.html0000644000004100000410000000041114203512426017547 0ustar www-datawww-data ./plugins/chromium/bamf.js0000644000004100000410000000042114203512426016006 0ustar www-datawww-datafunction onTabCreated (tab) { } function onTabRemoved (tabid) { } function onTabUpdated (tabid, changeInfo, tab) { } chrome.tabs.onUpdated.addListener (onTabUpdated); chrome.tabs.onCreated.addListener (onTabCreated); chrome.tabs.onRemoved.addListener (onTabRemoved); ./COPYING0000644000004100000410000010451314203512426012301 0ustar www-datawww-data GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ./src/0000755000004100000410000000000014203512426012031 5ustar www-datawww-data./src/bamf-tab.c0000644000004100000410000001600314203512426013646 0ustar www-datawww-data/* * Copyright (C) 2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: * Robert Carr * */ /** * SECTION:bamf-tab * @short_description: The base class for browser tabs * * #BamfTab is the base class that all tabs need to derive from. */ #include "bamf-tab.h" static void bamf_tab_dbus_iface_init (BamfDBusItemTabIface *iface); enum { PROP_0, PROP_LOCATION, PROP_XID, PROP_DESKTOP_ID, PROP_IS_FOREGROUND_TAB }; struct _BamfTabPrivate { BamfDBusItemTab *dbus_iface; }; G_DEFINE_ABSTRACT_TYPE_WITH_CODE (BamfTab, bamf_tab, BAMF_TYPE_VIEW, G_ADD_PRIVATE(BamfTab) G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_TAB, bamf_tab_dbus_iface_init)); static const gchar * bamf_tab_get_view_type (BamfView *view) { return "tab"; } static char * bamf_tab_get_stable_bus_name (BamfView *view) { return g_strdup_printf ("tab/%u", GPOINTER_TO_UINT (view)); } static void bamf_tab_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { BamfTab *self; self = BAMF_TAB (object); switch (property_id) { case PROP_LOCATION: g_value_set_string (value, bamf_tab_get_location (self)); break; case PROP_XID: g_value_set_uint64 (value, bamf_tab_get_xid (self)); break; case PROP_DESKTOP_ID: g_value_set_string (value, bamf_tab_get_desktop_id (self)); break; case PROP_IS_FOREGROUND_TAB: g_value_set_boolean (value, bamf_tab_get_is_foreground_tab (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void bamf_tab_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { BamfTab *self; self = BAMF_TAB (object); switch (property_id) { case PROP_LOCATION: _bamf_dbus_item_tab_set_location (self->priv->dbus_iface, g_value_get_string (value)); break; case PROP_DESKTOP_ID: _bamf_dbus_item_tab_set_desktop_id (self->priv->dbus_iface, g_value_get_string (value)); break; case PROP_XID: _bamf_dbus_item_tab_set_xid (self->priv->dbus_iface, g_value_get_uint64 (value)); break; case PROP_IS_FOREGROUND_TAB: _bamf_dbus_item_tab_set_is_foreground_tab (self->priv->dbus_iface, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } } static void bamf_tab_finalize (GObject *object) { BamfTab *self = BAMF_TAB (object); g_object_unref (self->priv->dbus_iface); G_OBJECT_CLASS (bamf_tab_parent_class)->finalize (object); } static gboolean on_dbus_handle_raise (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfTab *self) { g_dbus_method_invocation_return_value (invocation, NULL); bamf_tab_raise (self); return TRUE; } static gboolean on_dbus_handle_close (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfTab *self) { g_dbus_method_invocation_return_value (invocation, NULL); bamf_tab_close (self); return TRUE; } static void bamf_tab_preview_ready (BamfTab *self, const gchar *preview_data, gpointer user_data) { GDBusMethodInvocation *invocation; invocation = (GDBusMethodInvocation *)user_data; g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", preview_data)); } static gboolean on_dbus_handle_request_preview (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfTab *self) { bamf_tab_request_preview (self, bamf_tab_preview_ready, invocation); return TRUE; } static void bamf_tab_init (BamfTab *self) { self->priv = bamf_tab_get_instance_private (self); self->priv->dbus_iface = _bamf_dbus_item_tab_skeleton_new (); g_signal_connect (self->priv->dbus_iface, "handle-raise", G_CALLBACK (on_dbus_handle_raise), self); g_signal_connect (self->priv->dbus_iface, "handle-close", G_CALLBACK (on_dbus_handle_close), self); g_signal_connect (self->priv->dbus_iface, "handle-request-preview", G_CALLBACK (on_dbus_handle_request_preview), self); _bamf_dbus_item_object_skeleton_set_tab (BAMF_DBUS_ITEM_OBJECT_SKELETON (self), self->priv->dbus_iface); } static void bamf_tab_dbus_iface_init (BamfDBusItemTabIface *iface) { } static void bamf_tab_class_init (BamfTabClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); BamfViewClass *view_class = BAMF_VIEW_CLASS (klass); object_class->get_property = bamf_tab_get_property; object_class->set_property = bamf_tab_set_property; object_class->finalize = bamf_tab_finalize; view_class->view_type = bamf_tab_get_view_type; view_class->stable_bus_name = bamf_tab_get_stable_bus_name; g_object_class_override_property (object_class, PROP_LOCATION, "location"); g_object_class_override_property (object_class, PROP_DESKTOP_ID, "desktop-id"); g_object_class_override_property (object_class, PROP_XID, "xid"); g_object_class_override_property (object_class, PROP_IS_FOREGROUND_TAB, "is-foreground-tab"); } const gchar * bamf_tab_get_location (BamfTab *self) { g_return_val_if_fail (BAMF_IS_TAB (self), NULL); return _bamf_dbus_item_tab_get_location (self->priv->dbus_iface); } const gchar * bamf_tab_get_desktop_id (BamfTab *self) { g_return_val_if_fail (BAMF_IS_TAB (self), NULL); return _bamf_dbus_item_tab_get_desktop_id (self->priv->dbus_iface); } guint64 bamf_tab_get_xid (BamfTab *self) { g_return_val_if_fail (BAMF_IS_TAB (self), 0); return _bamf_dbus_item_tab_get_xid (self->priv->dbus_iface); } gboolean bamf_tab_get_is_foreground_tab (BamfTab *self) { g_return_val_if_fail (BAMF_IS_TAB (self), 0); return _bamf_dbus_item_tab_get_is_foreground_tab (self->priv->dbus_iface); } void bamf_tab_raise (BamfTab *self) { g_return_if_fail (BAMF_IS_TAB (self)); BAMF_TAB_GET_CLASS (self)->raise (self); } void bamf_tab_close (BamfTab *self) { g_return_if_fail (BAMF_IS_TAB (self)); BAMF_TAB_GET_CLASS (self)->close (self); } void bamf_tab_request_preview (BamfTab *self, BamfTabPreviewReadyCallback callback, gpointer user_data) { g_return_if_fail (BAMF_IS_TAB (self)); BAMF_TAB_GET_CLASS (self)->request_preview (self, callback, user_data); } ./src/bamf-window.h0000644000004100000410000000551014203512426014415 0ustar www-datawww-data/* * Copyright (C) 2010 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * */ #ifndef __BAMFWINDOW_H__ #define __BAMFWINDOW_H__ #include "bamf-view.h" #include "bamf-legacy-window.h" #include #include #include #define BAMF_TYPE_WINDOW (bamf_window_get_type ()) #define BAMF_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_WINDOW, BamfWindow)) #define BAMF_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_WINDOW)) #define BAMF_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_WINDOW, BamfWindowClass)) #define BAMF_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_WINDOW)) #define BAMF_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_WINDOW, BamfWindowClass)) typedef struct _BamfWindow BamfWindow; typedef struct _BamfWindowClass BamfWindowClass; typedef struct _BamfWindowPrivate BamfWindowPrivate; struct _BamfWindowClass { BamfViewClass parent; gboolean (*user_visible) (BamfWindow *window); gboolean (*is_urgent) (BamfWindow *window); guint32 (*get_xid) (BamfWindow *window); BamfLegacyWindow * (*get_window) (BamfWindow *window); }; struct _BamfWindow { BamfView parent; /* private */ BamfWindowPrivate *priv; }; GType bamf_window_get_type (void) G_GNUC_CONST; BamfLegacyWindow * bamf_window_get_window (BamfWindow *self); BamfWindow * bamf_window_get_transient (BamfWindow *self); const char * bamf_window_get_transient_path (BamfWindow *self); guint32 bamf_window_get_window_type (BamfWindow *self); guint32 bamf_window_get_xid (BamfWindow *window); guint32 bamf_window_get_pid (BamfWindow *window); gint bamf_window_get_stack_position (BamfWindow *window); char * bamf_window_get_string_hint (BamfWindow *self, const char* prop); char * bamf_window_get_application_id (BamfWindow *self); BamfWindowMaximizationType bamf_window_maximized (BamfWindow *self); gint bamf_window_get_monitor (BamfWindow *self); BamfWindow * bamf_window_new (BamfLegacyWindow *window); #endif ./src/bamf-daemon.c0000644000004100000410000001121514203512426014343 0ustar www-datawww-data/* * Copyright (C) 2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include "bamf-daemon.h" #include "bamf-matcher.h" #include "bamf-control.h" static BamfDaemon *instance = NULL; struct _BamfDaemonPrivate { BamfMatcher *matcher; BamfControl *control; GMainLoop *loop; }; G_DEFINE_TYPE_WITH_PRIVATE (BamfDaemon, bamf_daemon, G_TYPE_OBJECT); gboolean bamf_daemon_is_running (BamfDaemon *self) { g_return_val_if_fail (self, FALSE); if (self->priv->loop && g_main_loop_is_running (self->priv->loop)) { return TRUE; } return FALSE; } static void bamf_on_bus_acquired (GDBusConnection *connection, const gchar *name, BamfDaemon *self) { GError *error = NULL; g_return_if_fail (BAMF_IS_DAEMON (self)); g_debug ("Acquired a message bus connection"); g_dbus_connection_set_exit_on_close (connection, TRUE); self->priv->matcher = bamf_matcher_get_default (); self->priv->control = bamf_control_get_default (); g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->matcher), connection, BAMF_DBUS_MATCHER_PATH, &error); if (error) { g_critical ("Can't register BAMF matcher at path %s: %s", BAMF_DBUS_MATCHER_PATH, error->message); g_clear_error (&error); } g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->priv->control), connection, BAMF_DBUS_CONTROL_PATH, &error); if (error) { g_critical ("Can't register BAMF control at path %s: %s", BAMF_DBUS_CONTROL_PATH, error->message); g_clear_error (&error); } } static void bamf_on_name_acquired (GDBusConnection *connection, const gchar *name, BamfDaemon *self) { g_debug ("Acquired the name %s", name); } static void bamf_on_name_lost (GDBusConnection *connection, const gchar *name, BamfDaemon *self) { g_critical ("Lost the name %s, another BAMF daemon is currently running", name); bamf_daemon_stop (self); } void bamf_daemon_start (BamfDaemon *self) { g_return_if_fail (BAMF_IS_DAEMON (self)); if (bamf_daemon_is_running (self)) return; g_bus_own_name (G_BUS_TYPE_SESSION, BAMF_DBUS_SERVICE_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, (GBusAcquiredCallback) bamf_on_bus_acquired, (GBusNameAcquiredCallback) bamf_on_name_acquired, (GBusNameLostCallback) bamf_on_name_lost, self, NULL); g_main_loop_run (self->priv->loop); } void bamf_daemon_stop (BamfDaemon *self) { g_return_if_fail (BAMF_IS_DAEMON (self)); if (self->priv->matcher) { g_object_unref (self->priv->matcher); self->priv->matcher = NULL; } if (self->priv->control) { g_object_unref (self->priv->control); self->priv->control = NULL; } g_main_loop_quit (self->priv->loop); } static void bamf_daemon_dispose (GObject *object) { BamfDaemon *self = BAMF_DAEMON (object); bamf_daemon_stop (self); if (self->priv->loop) { g_main_loop_unref (self->priv->loop); self->priv->loop = NULL; } G_OBJECT_CLASS (bamf_daemon_parent_class)->dispose (object); } static void bamf_daemon_finalize (GObject *object) { instance = NULL; } static void bamf_daemon_init (BamfDaemon *self) { BamfDaemonPrivate *priv; priv = self->priv = bamf_daemon_get_instance_private (self); priv->loop = g_main_loop_new (NULL, FALSE); } static void bamf_daemon_class_init (BamfDaemonClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = bamf_daemon_dispose; object_class->finalize = bamf_daemon_finalize; } BamfDaemon * bamf_daemon_get_default (void) { if (!BAMF_IS_DAEMON (instance)) instance = (BamfDaemon *) g_object_new (BAMF_TYPE_DAEMON, NULL); return instance; } ./src/bamf-control.h0000644000004100000410000000507714203512426014576 0ustar www-datawww-data/* * Copyright (C) 2010-2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef __BAMFCONTROL_H__ #define __BAMFCONTROL_H__ #include #include #include #define BAMF_TYPE_CONTROL (bamf_control_get_type ()) #define BAMF_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_CONTROL, BamfControl)) #define BAMF_IS_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_CONTROL)) #define BAMF_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_CONTROL, BamfControlClass)) #define BAMF_IS_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_CONTROL)) #define BAMF_CONTROL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_CONTROL, BamfControlClass)) typedef struct _BamfControl BamfControl; typedef struct _BamfControlClass BamfControlClass; typedef struct _BamfControlPrivate BamfControlPrivate; struct _BamfControlClass { BamfDBusControlSkeletonClass parent; }; struct _BamfControl { BamfDBusControlSkeleton parent; /* private */ BamfControlPrivate *priv; }; GType bamf_control_get_type (void) G_GNUC_CONST; void bamf_control_register_application_for_pid (BamfControl *control, const char *application, gint32 pid); void bamf_control_insert_desktop_file (BamfControl *control, const char *path); void bamf_control_create_local_desktop_file (BamfControl *control, const char *desktop_file); void bamf_control_quit (BamfControl *control); BamfControl * bamf_control_get_default (void); #endif ./src/bamf-application.c0000644000004100000410000012454214203512426015413 0ustar www-datawww-data/* * Copyright (C) 2010-2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include "bamf-application.h" #include "bamf-window.h" #include "bamf-matcher.h" #include "bamf-legacy-window.h" #include "bamf-legacy-screen.h" #include "bamf-tab.h" #include #include static void bamf_application_dbus_application_iface_init (BamfDBusItemApplicationIface *iface); struct _BamfApplicationPrivate { BamfDBusItemApplication *dbus_iface; BamfApplicationType app_type; BamfView * main_child; GCancellable * cancellable; char * desktop_file; GList * desktop_file_list; char * wmclass; char ** mimes; gboolean show_stubs; }; G_DEFINE_TYPE_WITH_CODE (BamfApplication, bamf_application, BAMF_TYPE_VIEW, G_ADD_PRIVATE(BamfApplication) G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_APPLICATION, bamf_application_dbus_application_iface_init)); enum { SUPPORTED_MIMES_CHANGED, LAST_SIGNAL }; static guint application_signals[LAST_SIGNAL] = { 0 }; #define STUB_KEY "X-Ayatana-Appmenu-Show-Stubs" static void on_main_child_name_changed (BamfView *, const gchar *, const gchar *, BamfApplication *); void bamf_application_supported_mime_types_changed (BamfApplication *application, const gchar **new_mimes) { gchar **mimes = (gchar **) new_mimes; if (!new_mimes) { gchar *empty[] = {NULL}; mimes = g_strdupv (empty); } g_signal_emit_by_name (application->priv->dbus_iface, "supported-mime-types-changed", mimes); if (!new_mimes) { g_strfreev (mimes); mimes = NULL; } if (application->priv->mimes) g_strfreev (application->priv->mimes); application->priv->mimes = mimes; } static gboolean bamf_application_default_get_close_when_empty (BamfApplication *application) { return TRUE; } static gchar ** bamf_application_default_get_supported_mime_types (BamfApplication *application) { const char *desktop_file; char** mimes; desktop_file = bamf_application_get_desktop_file (application); if (!desktop_file) return NULL; GKeyFile* key_file = g_key_file_new (); if (!g_key_file_load_from_file (key_file, desktop_file, G_KEY_FILE_NONE, NULL)) { g_key_file_free (key_file); return NULL; } mimes = g_key_file_get_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_MIME_TYPE, NULL, NULL); g_signal_emit (application, application_signals[SUPPORTED_MIMES_CHANGED], 0, mimes); g_key_file_free (key_file); return mimes; } char ** bamf_application_get_supported_mime_types (BamfApplication *application) { gchar **mimes = NULL; g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL); if (application->priv->mimes) return g_strdupv (application->priv->mimes); if (BAMF_APPLICATION_GET_CLASS (application)->get_supported_mime_types) mimes = BAMF_APPLICATION_GET_CLASS (application)->get_supported_mime_types (application); application->priv->mimes = mimes; return g_strdupv (mimes); } BamfApplicationType bamf_application_get_application_type (BamfApplication *application) { g_return_val_if_fail (BAMF_IS_APPLICATION (application), BAMF_APPLICATION_UNKNOWN); return application->priv->app_type; } void bamf_application_set_application_type (BamfApplication *application, BamfApplicationType type) { g_return_if_fail (BAMF_IS_APPLICATION (application)); g_return_if_fail (type >= 0 && type < BAMF_APPLICATION_UNKNOWN); application->priv->app_type = type; } const char * bamf_application_get_desktop_file (BamfApplication *application) { BamfApplicationPrivate *priv; g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL); priv = application->priv; return priv->desktop_file; } const char * bamf_application_get_wmclass (BamfApplication *application) { BamfApplicationPrivate *priv; g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL); priv = application->priv; return priv->wmclass; } static gboolean icon_name_is_valid (const char *name) { GtkIconTheme *icon_theme; GtkIconInfo *icon_info; if (!name || name[0] == '\0') return FALSE; if (g_file_test (name, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) return TRUE; // Please note that since gtk 3.14 gtk_icon_theme_has_icon stopped working. icon_theme = gtk_icon_theme_get_default (); icon_info = gtk_icon_theme_lookup_icon (icon_theme, name, -1, 0); if (icon_info != NULL) { g_object_unref (icon_info); return TRUE; } return FALSE; } static gboolean icon_name_is_generic (const char *name) { BamfMatcher *matcher = bamf_matcher_get_default (); return !bamf_matcher_is_valid_process_prefix (matcher, name); } static void bamf_application_setup_icon_and_name (BamfApplication *self, gboolean force) { BamfWindow *window; BamfLegacyWindow *legacy_window; GDesktopAppInfo *desktop; GKeyFile * keyfile; GIcon *gicon; const char *class; char *icon = NULL, *generic_icon = NULL, *name = NULL; GError *error; g_return_if_fail (BAMF_IS_APPLICATION (self)); if (!force) { if (bamf_view_get_icon (BAMF_VIEW (self)) && bamf_view_get_name (BAMF_VIEW (self))) return; } if (self->priv->desktop_file) { keyfile = g_key_file_new (); if (!g_key_file_load_from_file (keyfile, self->priv->desktop_file, G_KEY_FILE_NONE, NULL)) { g_key_file_free (keyfile); return; } desktop = g_desktop_app_info_new_from_keyfile (keyfile); if (!G_IS_APP_INFO (desktop)) { g_key_file_free (keyfile); return; } gicon = g_app_info_get_icon (G_APP_INFO (desktop)); name = g_strdup (g_app_info_get_display_name (G_APP_INFO (desktop))); if (gicon) { icon = g_icon_to_string (gicon); if (!icon_name_is_valid (icon)) { g_free (icon); icon = NULL; } } if (!icon) { icon = g_strdup (BAMF_APPLICATION_DEFAULT_ICON); } if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL)) { /* This will error to return false, which is okay as it seems unlikely anyone will want to set this flag except to turn off the stub menus. */ self->priv->show_stubs = g_key_file_get_boolean (keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL); } if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_FULLNAME, NULL)) { /* Grab the better name if its available */ gchar *fullname = NULL; error = NULL; fullname = g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_FULLNAME, NULL, &error); if (error != NULL) { g_error_free (error); g_free (fullname); } else { g_free (name); name = fullname; } } g_object_unref (desktop); g_key_file_free (keyfile); } else if (BAMF_IS_WINDOW (self->priv->main_child)) { name = g_strdup (bamf_view_get_name (self->priv->main_child)); window = BAMF_WINDOW (self->priv->main_child); legacy_window = bamf_window_get_window (window); class = bamf_legacy_window_get_class_name (legacy_window); if (class) { icon = g_utf8_strdown (class, -1); if (icon_name_is_valid (icon)) { if (icon_name_is_generic (icon)) { generic_icon = icon; icon = NULL; } } else { g_free (icon); icon = NULL; } } if (!icon) { const char *exec = bamf_legacy_window_get_exec_string (legacy_window); icon = bamf_matcher_get_trimmed_exec (bamf_matcher_get_default (), exec); if (icon_name_is_valid (icon)) { if (icon_name_is_generic (icon)) { g_free (generic_icon); generic_icon = icon; icon = NULL; } } else { g_free (icon); icon = NULL; } } if (!icon) { icon = bamf_legacy_window_save_mini_icon (legacy_window); if (!icon) { if (generic_icon) { icon = generic_icon; generic_icon = NULL; } else { icon = g_strdup (BAMF_APPLICATION_DEFAULT_ICON); } } } g_free (generic_icon); generic_icon = NULL; } bamf_view_set_icon (BAMF_VIEW (self), icon); bamf_view_set_name (BAMF_VIEW (self), name); g_free (name); g_free (icon); } void bamf_application_set_desktop_file (BamfApplication *application, const char * desktop_file) { g_return_if_fail (BAMF_IS_APPLICATION (application)); if (g_strcmp0 (application->priv->desktop_file, desktop_file) == 0) return; g_free (application->priv->desktop_file); application->priv->desktop_file = NULL; if (desktop_file && desktop_file[0] != '\0') application->priv->desktop_file = g_strdup (desktop_file); if (application->priv->main_child) { g_signal_handlers_disconnect_by_func (application->priv->main_child, on_main_child_name_changed, application); } g_signal_emit_by_name (application, "desktop-file-updated", application->priv->desktop_file); bamf_application_setup_icon_and_name (application, TRUE); } gboolean bamf_application_set_desktop_file_from_id (BamfApplication *application, const char *desktop_id) { GDesktopAppInfo *info; const char *filename; info = g_desktop_app_info_new (desktop_id); if (info == NULL) { g_warning ("Failed to load desktop file from desktop ID: %s", desktop_id); return FALSE; } filename = g_desktop_app_info_get_filename (info); bamf_application_set_desktop_file (application, filename); g_object_unref (G_OBJECT (info)); return TRUE; } static GFile * try_create_subdir (GFile *parent, const gchar *child_name, GCancellable *cancellable) { GFile *child; GError *error = NULL; child = g_file_get_child (parent, child_name); g_return_val_if_fail (G_IS_FILE (child), NULL); g_file_make_directory_with_parents (child, cancellable, &error); if (error) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) { g_error ("Impossible to create `%s` directory: %s", child_name, error->message); g_clear_object (&child); } g_error_free (error); } return child; } static GFile * try_create_child (GFile *parent, const gchar *basename, const gchar *extension, GCancellable *cancellable) { gchar *down, *child_name; down = g_ascii_strdown (basename, -1); g_strdelimit (down, "/\\&%\"'!?`*.;:^|()= <>[]{}", '_'); child_name = g_strconcat (down, extension, NULL); GFile *child = g_file_get_child (parent, child_name); g_return_val_if_fail (G_IS_FILE (child), NULL); if (g_file_query_exists (child, cancellable)) g_clear_object (&child); g_free (child_name); g_free (down); return child; } gboolean try_create_local_desktop_data (GFile *apps_dir, GFile *icons_dir, const char *basename, GFile **out_desktop_file, GFile **out_icon_file, GCancellable *cancellable) { g_return_val_if_fail (out_desktop_file, FALSE); if (!apps_dir) { *out_desktop_file = NULL; g_warn_if_reached (); } *out_desktop_file = try_create_child (apps_dir, basename, ".desktop", cancellable); if (G_IS_FILE (*out_desktop_file)) { if (G_IS_FILE (icons_dir) && out_icon_file) *out_icon_file = try_create_child (icons_dir, basename, ".png", cancellable); return TRUE; } return FALSE; } gboolean bamf_application_create_local_desktop_file (BamfApplication *self) { BamfApplicationPrivate *priv; BamfLegacyWindow *window; BamfMatcher *matcher; GKeyFile *key_file; const gchar *name, *icon, *iclass, *nclass, *class, *exec, *path, *curdesktop; GFile *data_dir, *apps_dir, *icons_dir, *desktop_file, *icon_file, *mini_icon; GError *error = NULL; g_return_val_if_fail (BAMF_IS_APPLICATION (self), FALSE); priv = self->priv; if (priv->desktop_file || !BAMF_IS_WINDOW (priv->main_child)) { return FALSE; } window = bamf_window_get_window (BAMF_WINDOW (priv->main_child)); exec = bamf_legacy_window_get_exec_string (window); if (!exec) { return FALSE; } matcher = bamf_matcher_get_default (); data_dir = g_file_new_for_path (g_get_user_data_dir ()); name = bamf_view_get_name (BAMF_VIEW (self)); icon = bamf_view_get_icon (BAMF_VIEW (self)); nclass = bamf_legacy_window_get_class_name (window); iclass = bamf_legacy_window_get_class_instance_name (window); path = bamf_legacy_window_get_working_dir (window); mini_icon = bamf_legacy_window_get_saved_mini_icon (window); curdesktop = g_getenv ("XDG_CURRENT_DESKTOP"); if (!bamf_matcher_is_valid_class_name (matcher, iclass)) iclass = NULL; if (!bamf_matcher_is_valid_class_name (matcher, nclass)) nclass = NULL; apps_dir = try_create_subdir (data_dir, "applications", priv->cancellable); icons_dir = NULL; if (!G_IS_FILE (apps_dir)) { g_object_unref (data_dir); return FALSE; } if (icon && G_IS_FILE (mini_icon)) icons_dir = try_create_subdir (data_dir, "icons", priv->cancellable); g_clear_object (&data_dir); desktop_file = NULL; icon_file = NULL; class = (nclass) ? nclass : iclass; if (class) { try_create_local_desktop_data (apps_dir, icons_dir, class, &desktop_file, &icon_file, priv->cancellable); } if (!G_IS_FILE (desktop_file)) { gchar *trimmed_exec = bamf_matcher_get_trimmed_exec (matcher, exec); try_create_local_desktop_data (apps_dir, icons_dir, trimmed_exec, &desktop_file, &icon_file, priv->cancellable); g_free (trimmed_exec); } if (!G_IS_FILE (desktop_file)) { try_create_local_desktop_data (apps_dir, icons_dir, exec, &desktop_file, &icon_file, priv->cancellable); } g_object_unref (apps_dir); if (!G_IS_FILE (desktop_file)) { g_critical ("Impossible to find a valid path where to save a .desktop file"); g_clear_object (&icons_dir); g_clear_object (&icon_file); return FALSE; } if (G_IS_FILE (icons_dir) && !G_IS_FILE (icon_file)) { gchar *basename = g_file_get_basename (mini_icon); icon_file = try_create_child (icons_dir, basename+1, ".png", priv->cancellable); g_free (basename); } g_clear_object (&icons_dir); if (G_IS_FILE (icon_file)) { if (!g_file_copy (mini_icon, icon_file, G_FILE_COPY_NONE, priv->cancellable, NULL, NULL, &error)) { g_warning ("Impossible to copy icon to final destination: %s", error->message); g_clear_error (&error); g_clear_object (&icon_file); } } key_file = g_key_file_new (); g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, "Encoding", "UTF-8"); g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_VERSION, "1.0"); g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TYPE, G_KEY_FILE_DESKTOP_TYPE_APPLICATION); if (name) { g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, name); } if (icon_file) { gchar *basename = g_file_get_basename (icon_file); g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, basename); bamf_view_set_icon (BAMF_VIEW (self), basename); g_free (basename); g_clear_object (&icon_file); } else if (icon) { g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, icon); } if (path && path[0] != '\0') { gchar *current_dir = g_get_current_dir (); if (g_strcmp0 (current_dir, path) != 0) { g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_PATH, path); } g_free (current_dir); } g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, exec); /* It would be nice to know if the app support it from a win property */ g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY, FALSE); if (class) { g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS, class); } if (curdesktop) { gchar** show_in_list = g_strsplit (curdesktop, ":", 0); g_key_file_set_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN, (const gchar * const *) show_in_list, g_strv_length (show_in_list)); gchar *generator = g_strdup_printf ("X-%s-Generated", show_in_list[0]); g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, generator, TRUE); g_free (generator); g_strfreev (show_in_list); } else { g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, "X-BAMF-Generated", TRUE); } gsize data_length = 0; gchar *data = g_key_file_to_data (key_file, &data_length, &error); g_key_file_free (key_file); if (error) { g_critical ("Impossible to generate local desktop file: %s", error->message); g_clear_error (&error); g_clear_pointer (&data, g_free); } if (data) { g_file_replace_contents (desktop_file, data, data_length, NULL, FALSE, G_FILE_CREATE_NONE, NULL, priv->cancellable, &error); g_free (data); if (error) { g_critical ("Impossible to create local desktop file: %s", error->message); g_clear_error (&error); g_object_unref (desktop_file); return FALSE; } } gchar *desktop_path = g_file_get_path (desktop_file); g_object_unref (desktop_file); bamf_application_set_desktop_file (self, desktop_path); g_free (desktop_path); return TRUE; } void bamf_application_set_wmclass (BamfApplication *application, const char *wmclass) { g_return_if_fail (BAMF_IS_APPLICATION (application)); if (application->priv->wmclass) g_free (application->priv->wmclass); if (wmclass && wmclass[0] != '\0') application->priv->wmclass = g_strdup (wmclass); else application->priv->wmclass = NULL; } GVariant * bamf_application_get_xids (BamfApplication *application) { GList *l; GVariantBuilder b; BamfView *view; guint32 xid; g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL); g_variant_builder_init (&b, G_VARIANT_TYPE ("(au)")); g_variant_builder_open (&b, G_VARIANT_TYPE ("au")); for (l = bamf_view_get_children (BAMF_VIEW (application)); l; l = l->next) { view = l->data; if (BAMF_IS_WINDOW (view)) xid = bamf_window_get_xid (BAMF_WINDOW (view)); else if (BAMF_IS_TAB (view)) xid = bamf_tab_get_xid (BAMF_TAB (view)); else continue; g_variant_builder_add (&b, "u", xid); } g_variant_builder_close (&b); return g_variant_builder_end (&b); } gboolean bamf_application_contains_similar_to_window (BamfApplication *self, BamfWindow *bamf_window) { GList *children, *l; BamfView *child; g_return_val_if_fail (BAMF_IS_APPLICATION (self), FALSE); g_return_val_if_fail (BAMF_IS_WINDOW (bamf_window), FALSE); BamfLegacyWindow *window = bamf_window_get_window (bamf_window); const char *window_class = bamf_legacy_window_get_class_name (window); const char *instance_name = bamf_legacy_window_get_class_instance_name (window); children = bamf_view_get_children (BAMF_VIEW (self)); for (l = children; l; l = l->next) { child = l->data; if (!BAMF_IS_WINDOW (child)) continue; window = bamf_window_get_window (BAMF_WINDOW (child)); const char *owned_win_class = bamf_legacy_window_get_class_name (window); const char *owned_instance = bamf_legacy_window_get_class_instance_name (window); if (g_strcmp0 (window_class, owned_win_class) == 0 && g_strcmp0 (instance_name, owned_instance) == 0) { return TRUE; } } return FALSE; } gboolean bamf_application_manages_xid (BamfApplication *application, guint32 xid) { return (bamf_application_get_window (application, xid) != NULL); } BamfWindow * bamf_application_get_window (BamfApplication *application, guint32 xid) { GList *l; g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL); for (l = bamf_view_get_children (BAMF_VIEW (application)); l; l = l->next) { BamfView *view = l->data; if (!BAMF_IS_WINDOW (view)) continue; BamfWindow *window = BAMF_WINDOW (view); if (bamf_window_get_xid (window) == xid) { return window; } } return NULL; } static const char * bamf_application_get_view_type (BamfView *view) { return "application"; } static char * bamf_application_get_stable_bus_name (BamfView *view) { BamfApplication *self; g_return_val_if_fail (BAMF_IS_APPLICATION (view), NULL); self = BAMF_APPLICATION (view); if (self->priv->desktop_file) return g_strdup_printf ("application/%i", abs (g_str_hash (self->priv->desktop_file))); return g_strdup_printf ("application/%p", view); } static void bamf_application_ensure_flags (BamfApplication *self) { gboolean urgent = FALSE, visible = FALSE, running = FALSE, active = FALSE; GList *l; BamfView *view; for (l = bamf_view_get_children (BAMF_VIEW (self)); l; l = l->next) { view = l->data; if (!BAMF_IS_VIEW (view)) continue; running = TRUE; if (!BAMF_IS_WINDOW (view) && !BAMF_IS_TAB (view)) continue; if (bamf_view_is_urgent (view)) urgent = TRUE; if (bamf_view_is_user_visible (view)) visible = TRUE; if (bamf_view_is_active (view)) active = TRUE; if (urgent && visible && active) break; } gboolean close_when_empty = bamf_application_get_close_when_empty (self); bamf_view_set_urgent (BAMF_VIEW (self), urgent); bamf_view_set_user_visible (BAMF_VIEW (self), (visible || !close_when_empty)); bamf_view_set_running (BAMF_VIEW (self), (running || !close_when_empty)); bamf_view_set_active (BAMF_VIEW (self), active); } static void view_active_changed (BamfView *view, gboolean active, BamfApplication *self) { bamf_application_ensure_flags (self); } static void view_urgent_changed (BamfView *view, gboolean urgent, BamfApplication *self) { bamf_application_ensure_flags (self); } static void view_visible_changed (BamfView *view, gboolean visible, BamfApplication *self) { bamf_application_ensure_flags (self); } static void view_xid_changed (GObject *object, GParamSpec *pspec, gpointer user_data) { BamfApplication *self; self = (BamfApplication *)user_data; bamf_application_ensure_flags (self); } static void on_main_child_name_changed (BamfView *child, const gchar *old_name, const gchar *new_name, BamfApplication *self) { bamf_view_set_name (BAMF_VIEW (self), new_name); } static void bamf_application_set_main_child (BamfApplication *self, BamfView *child) { if (self->priv->main_child == child) return; if (self->priv->main_child) { g_object_remove_weak_pointer (G_OBJECT (self->priv->main_child), (gpointer*) &self->priv->main_child); g_signal_handlers_disconnect_by_func (self->priv->main_child, on_main_child_name_changed, self); } self->priv->main_child = child; if (self->priv->main_child) { g_object_add_weak_pointer (G_OBJECT (self->priv->main_child), (gpointer*) &self->priv->main_child); if (!self->priv->desktop_file) { g_signal_connect (child, "name-changed", G_CALLBACK (on_main_child_name_changed), self); } } } BamfView * bamf_application_get_main_child (BamfApplication *self) { g_return_val_if_fail (BAMF_IS_APPLICATION (self), NULL); return self->priv->main_child; } static void bamf_application_child_added (BamfView *view, BamfView *child) { BamfApplication *application; BamfWindow *window = NULL; gboolean reset_emblems = FALSE; application = BAMF_APPLICATION (view); g_signal_connect (G_OBJECT (child), "active-changed", (GCallback) view_active_changed, view); g_signal_connect (G_OBJECT (child), "urgent-changed", (GCallback) view_urgent_changed, view); g_signal_connect (G_OBJECT (child), "user-visible-changed", (GCallback) view_visible_changed, view); if (BAMF_IS_WINDOW (child)) { window = BAMF_WINDOW (child); } else if (BAMF_IS_TAB (child)) { g_signal_connect (G_OBJECT (child), "notify::xid", (GCallback) view_xid_changed, view); } if (application->priv->main_child) { if (window && BAMF_IS_WINDOW (application->priv->main_child)) { BamfWindow *main_window = BAMF_WINDOW (application->priv->main_child); if (bamf_window_get_window_type (main_window) != BAMF_WINDOW_NORMAL && bamf_window_get_window_type (window) == BAMF_WINDOW_NORMAL) { bamf_application_set_main_child (application, child); } } } else { bamf_application_set_main_child (application, child); } bamf_application_ensure_flags (BAMF_APPLICATION (view)); if (!application->priv->desktop_file && application->priv->main_child == child) reset_emblems = TRUE; bamf_application_setup_icon_and_name (application, reset_emblems); } static char * bamf_application_favorite_from_list (BamfApplication *self, GList *desktop_list) { BamfMatcher *matcher; GList *favs, *l; char *result = NULL; const char *desktop_class; g_return_val_if_fail (BAMF_IS_APPLICATION (self), NULL); matcher = bamf_matcher_get_default (); favs = bamf_matcher_get_favorites (matcher); if (favs) { for (l = favs; l; l = l->next) { if (g_list_find_custom (desktop_list, l->data, (GCompareFunc) g_strcmp0)) { desktop_class = bamf_matcher_get_desktop_file_class (matcher, l->data); if (!desktop_class || g_strcmp0 (self->priv->wmclass, desktop_class) == 0) { result = l->data; break; } } } } return result; } static void bamf_application_set_desktop_file_from_list (BamfApplication *self, GList *list) { BamfApplicationPrivate *priv; GList *l; char *desktop_file; g_return_if_fail (BAMF_IS_APPLICATION (self)); g_return_if_fail (list); priv = self->priv; if (priv->desktop_file_list) { g_list_free_full (priv->desktop_file_list, g_free); priv->desktop_file_list = NULL; } for (l = list; l; l = l->next) priv->desktop_file_list = g_list_prepend (priv->desktop_file_list, g_strdup (l->data)); priv->desktop_file_list = g_list_reverse (priv->desktop_file_list); desktop_file = bamf_application_favorite_from_list (self, priv->desktop_file_list); /* items, after reversing them, are in priority order */ if (!desktop_file) desktop_file = list->data; bamf_application_set_desktop_file (self, desktop_file); } static void bamf_application_child_removed (BamfView *view, BamfView *child) { BamfApplication *self = BAMF_APPLICATION (view); GList *children, *l; bamf_application_ensure_flags (self); children = bamf_view_get_children (view); if (self->priv->main_child == child) { /* Giving priority to older windows, and BamfView has a reversed list */ children = g_list_last (children); bamf_application_set_main_child (self, (children ? children->data : NULL)); if (self->priv->app_type == BAMF_APPLICATION_SYSTEM) { /* We check if we have a better target in next windows */ for (l = children; l; l = l->prev) { if (bamf_window_get_window_type (BAMF_WINDOW (l->data)) == BAMF_WINDOW_NORMAL) { bamf_application_set_main_child (self, l->data); break; } } } if (self->priv->main_child) { gboolean reset_emblems = (!self->priv->desktop_file); bamf_application_setup_icon_and_name (self, reset_emblems); } } if (!children && bamf_application_get_close_when_empty (self)) { bamf_view_close (view); } } static gboolean bamf_application_starting_changed (BamfView *view, gboolean starting) { if (starting) { bamf_view_set_user_visible (view, TRUE); } else { bamf_application_ensure_flags (BAMF_APPLICATION (view)); if (!bamf_view_is_running (view)) bamf_view_close (view); } return TRUE; } static void matcher_favorites_changed (BamfMatcher *matcher, BamfApplication *self) { char *new_desktop_file = NULL; g_return_if_fail (BAMF_IS_APPLICATION (self)); g_return_if_fail (BAMF_IS_MATCHER (matcher)); new_desktop_file = bamf_application_favorite_from_list (self, self->priv->desktop_file_list); if (new_desktop_file) { bamf_application_set_desktop_file (self, new_desktop_file); } } static void on_child_added (BamfApplication *self, const gchar *child_path, gpointer _not_used) { g_return_if_fail (BAMF_IS_APPLICATION (self)); g_signal_emit_by_name (self->priv->dbus_iface, "window-added", child_path); } static void on_child_removed (BamfApplication *self, const gchar *child_path, gpointer _not_used) { g_return_if_fail (BAMF_IS_APPLICATION (self)); g_signal_emit_by_name (self->priv->dbus_iface, "window-removed", child_path); } static void on_desktop_file_updated (BamfApplication *self, const gchar *file, gpointer _not_used) { g_return_if_fail (BAMF_IS_APPLICATION (self)); g_signal_emit_by_name (self->priv->dbus_iface, "desktop-file-updated", file); } static gboolean on_dbus_handle_show_stubs (BamfDBusItemApplication *interface, GDBusMethodInvocation *invocation, BamfApplication *self) { gboolean show_stubs = bamf_application_get_show_stubs (self); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", show_stubs)); return TRUE; } static gboolean on_dbus_handle_xids (BamfDBusItemApplication *interface, GDBusMethodInvocation *invocation, BamfApplication *self) { GVariant *xids = bamf_application_get_xids (self); g_dbus_method_invocation_return_value (invocation, xids); return TRUE; } static gboolean on_dbus_handle_focusable_child (BamfDBusItemApplication *interface, GDBusMethodInvocation *invocation, BamfApplication *self) { GVariant *out_variant; BamfView *focusable_child; out_variant = NULL; focusable_child = bamf_application_get_focusable_child (self); if (focusable_child == NULL) { out_variant = g_variant_new("(s)", ""); } else { const gchar *path; path = bamf_view_get_path (BAMF_VIEW (focusable_child)); out_variant = g_variant_new("(s)", path); } g_dbus_method_invocation_return_value (invocation, out_variant); return TRUE; } static gboolean on_dbus_handle_desktop_file (BamfDBusItemApplication *interface, GDBusMethodInvocation *invocation, BamfApplication *self) { const char *desktop_file = self->priv->desktop_file ? self->priv->desktop_file : ""; g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", desktop_file)); return TRUE; } static gboolean on_dbus_handle_supported_mime_types (BamfDBusItemApplication *interface, GDBusMethodInvocation *invocation, BamfApplication *self) { GVariant *list; GVariant *value; gchar **mimes = bamf_application_get_supported_mime_types (self); if (mimes) { list = g_variant_new_strv ((const gchar**) mimes, -1); g_strfreev (mimes); } else { list = g_variant_new_strv (NULL, 0); } value = g_variant_new ("(@as)", list); g_dbus_method_invocation_return_value (invocation, value); return TRUE; } static gboolean on_dbus_handle_application_menu (BamfDBusItemApplication *interface, GDBusMethodInvocation *invocation, BamfApplication *self) { gchar *name, *path; bamf_application_get_application_menu (self, &name, &path); name = name ? name : ""; path = path ? path : ""; g_dbus_method_invocation_return_value (invocation, g_variant_new ("(ss)", name, path)); return TRUE; } static gboolean on_dbus_handle_application_type (BamfDBusItemApplication *interface, GDBusMethodInvocation *invocation, BamfApplication *self) { const char *type = ""; switch (self->priv->app_type) { case BAMF_APPLICATION_SYSTEM: type = "system"; break; case BAMF_APPLICATION_WEB: type = "webapp"; break; default: type = "unknown"; } g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", type)); return TRUE; } static void bamf_application_dispose (GObject *object) { BamfApplication *app; BamfApplicationPrivate *priv; app = BAMF_APPLICATION (object); priv = app->priv; if (priv->desktop_file) { g_free (priv->desktop_file); priv->desktop_file = NULL; } if (priv->desktop_file_list) { g_list_free_full (priv->desktop_file_list, g_free); priv->desktop_file_list = NULL; } if (priv->wmclass) { g_free (priv->wmclass); priv->wmclass = NULL; } if (priv->main_child) { g_object_remove_weak_pointer (G_OBJECT (priv->main_child), (gpointer*) &priv->main_child); g_signal_handlers_disconnect_by_data (priv->main_child, app); priv->main_child = NULL; } if (priv->cancellable) { g_cancellable_cancel (priv->cancellable); g_object_unref (priv->cancellable); priv->cancellable = NULL; } g_strfreev (priv->mimes); priv->mimes = NULL; g_signal_handlers_disconnect_by_func (G_OBJECT (bamf_matcher_get_default ()), matcher_favorites_changed, object); G_OBJECT_CLASS (bamf_application_parent_class)->dispose (object); } static void bamf_application_finalize (GObject *object) { BamfApplication *self; self = BAMF_APPLICATION (object); g_object_unref (self->priv->dbus_iface); G_OBJECT_CLASS (bamf_application_parent_class)->finalize (object); } static void bamf_application_init (BamfApplication * self) { BamfApplicationPrivate *priv; priv = self->priv = bamf_application_get_instance_private (self); priv->app_type = BAMF_APPLICATION_SYSTEM; priv->show_stubs = TRUE; priv->cancellable = g_cancellable_new (); /* Initializing the dbus interface */ priv->dbus_iface = _bamf_dbus_item_application_skeleton_new (); /* We need to connect to the object own signals to redirect them to the dbus * interface */ g_signal_connect (self, "child-added", G_CALLBACK (on_child_added), NULL); g_signal_connect (self, "child-removed", G_CALLBACK (on_child_removed), NULL); g_signal_connect (self, "desktop-file-updated", G_CALLBACK (on_desktop_file_updated), NULL); /* Registering signal callbacks to reply to dbus method calls */ g_signal_connect (priv->dbus_iface, "handle-show-stubs", G_CALLBACK (on_dbus_handle_show_stubs), self); g_signal_connect (priv->dbus_iface, "handle-xids", G_CALLBACK (on_dbus_handle_xids), self); g_signal_connect (priv->dbus_iface, "handle-focusable-child", G_CALLBACK (on_dbus_handle_focusable_child), self); g_signal_connect (priv->dbus_iface, "handle-desktop-file", G_CALLBACK (on_dbus_handle_desktop_file), self); g_signal_connect (priv->dbus_iface, "handle-supported-mime-types", G_CALLBACK (on_dbus_handle_supported_mime_types), self); g_signal_connect (priv->dbus_iface, "handle-application-menu", G_CALLBACK (on_dbus_handle_application_menu), self); g_signal_connect (priv->dbus_iface, "handle-application-type", G_CALLBACK (on_dbus_handle_application_type), self); /* Setting the interface for the dbus object */ _bamf_dbus_item_object_skeleton_set_application (BAMF_DBUS_ITEM_OBJECT_SKELETON (self), priv->dbus_iface); g_signal_connect (G_OBJECT (bamf_matcher_get_default ()), "favorites-changed", (GCallback) matcher_favorites_changed, self); } static void bamf_application_dbus_application_iface_init (BamfDBusItemApplicationIface *iface) { } static void bamf_application_class_init (BamfApplicationClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); BamfViewClass *view_class = BAMF_VIEW_CLASS (klass); object_class->dispose = bamf_application_dispose; object_class->finalize = bamf_application_finalize; view_class->view_type = bamf_application_get_view_type; view_class->child_added = bamf_application_child_added; view_class->child_removed = bamf_application_child_removed; view_class->starting_changed = bamf_application_starting_changed; view_class->stable_bus_name = bamf_application_get_stable_bus_name; klass->get_supported_mime_types = bamf_application_default_get_supported_mime_types; klass->get_close_when_empty = bamf_application_default_get_close_when_empty; klass->supported_mimes_changed = bamf_application_supported_mime_types_changed; application_signals[SUPPORTED_MIMES_CHANGED] = g_signal_new ("supported-mimes-changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfApplicationClass, supported_mimes_changed), NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRV); } BamfApplication * bamf_application_new (void) { BamfApplication *application; application = (BamfApplication *) g_object_new (BAMF_TYPE_APPLICATION, NULL); return application; } BamfApplication * bamf_application_new_from_desktop_file (const char * desktop_file) { BamfApplication *application; application = (BamfApplication *) g_object_new (BAMF_TYPE_APPLICATION, NULL); bamf_application_set_desktop_file (application, desktop_file); return application; } BamfApplication * bamf_application_new_from_desktop_files (GList *desktop_files) { BamfApplication *application; application = (BamfApplication *) g_object_new (BAMF_TYPE_APPLICATION, NULL); bamf_application_set_desktop_file_from_list (application, desktop_files); return application; } BamfApplication * bamf_application_new_with_wmclass (const char *wmclass) { BamfApplication *application; application = (BamfApplication *) g_object_new (BAMF_TYPE_APPLICATION, NULL); bamf_application_set_wmclass (application, wmclass); return application; } gboolean bamf_application_get_show_stubs (BamfApplication *application) { g_return_val_if_fail (BAMF_IS_APPLICATION(application), TRUE); return application->priv->show_stubs; } gboolean bamf_application_get_close_when_empty (BamfApplication *application) { g_return_val_if_fail (BAMF_IS_APPLICATION(application), FALSE); if (BAMF_APPLICATION_GET_CLASS (application)->get_close_when_empty) { return BAMF_APPLICATION_GET_CLASS (application)->get_close_when_empty(application); } return TRUE; } void bamf_application_get_application_menu (BamfApplication *application, gchar **name, gchar **object_path) { g_return_if_fail (BAMF_IS_APPLICATION (application)); if (BAMF_APPLICATION_GET_CLASS (application)->get_application_menu) { BAMF_APPLICATION_GET_CLASS (application)->get_application_menu (application, name, object_path); } else { *name = NULL; *object_path = NULL; } } BamfView * bamf_application_get_focusable_child (BamfApplication *application) { g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL); if (BAMF_APPLICATION_GET_CLASS (application)->get_focusable_child) { return BAMF_APPLICATION_GET_CLASS (application)->get_focusable_child (application); } return NULL; } ./src/bamf-legacy-window.h0000644000004100000410000002076014203512426015663 0ustar www-datawww-data/* * Copyright (C) 2010 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * */ #ifndef __BAMFLEGACY_WINDOW_H__ #define __BAMFLEGACY_WINDOW_H__ #include "config.h" #include "bamf-view.h" #include #include #include #include #define BAMF_TYPE_LEGACY_WINDOW (bamf_legacy_window_get_type ()) #define BAMF_LEGACY_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_LEGACY_WINDOW, BamfLegacyWindow)) #define BAMF_IS_LEGACY_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_LEGACY_WINDOW)) #define BAMF_LEGACY_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_LEGACY_WINDOW, BamfLegacyWindowClass)) #define BAMF_IS_LEGACY_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_LEGACY_WINDOW)) #define BAMF_LEGACY_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_LEGACY_WINDOW, BamfLegacyWindowClass)) #define BAMF_LEGACY_WINDOW_SIGNAL_NAME_CHANGED "name-changed" #define BAMF_LEGACY_WINDOW_SIGNAL_ROLE_CHANGED "role-changed" #define BAMF_LEGACY_WINDOW_SIGNAL_CLASS_CHANGED "class-changed" #define BAMF_LEGACY_WINDOW_SIGNAL_STATE_CHANGED "state-changed" #define BAMF_LEGACY_WINDOW_SIGNAL_GEOMETRY_CHANGED "geometry-changed" #define BAMF_LEGACY_WINDOW_SIGNAL_CLOSED "closed" typedef struct _BamfLegacyWindow BamfLegacyWindow; typedef struct _BamfLegacyWindowClass BamfLegacyWindowClass; typedef struct _BamfLegacyWindowPrivate BamfLegacyWindowPrivate; typedef enum { BAMF_WINDOW_NORMAL, /* document/app window */ BAMF_WINDOW_DESKTOP, /* desktop background */ BAMF_WINDOW_DOCK, /* panel */ BAMF_WINDOW_DIALOG, /* dialog */ BAMF_WINDOW_TOOLBAR, /* tearoff toolbar */ BAMF_WINDOW_MENU, /* tearoff menu */ BAMF_WINDOW_UTILITY, /* palette/toolbox window */ BAMF_WINDOW_SPLASHSCREEN /* splash screen */ } BamfWindowType; typedef enum { BAMF_WINDOW_FLOATING, BAMF_WINDOW_HORIZONTAL_MAXIMIZED, BAMF_WINDOW_VERTICAL_MAXIMIZED, BAMF_WINDOW_MAXIMIZED } BamfWindowMaximizationType; struct _BamfLegacyWindowClass { GObjectClass parent; BamfLegacyWindow * (*get_transient) (BamfLegacyWindow *legacy_window); const char * (*get_name) (BamfLegacyWindow *legacy_window); const char * (*get_role) (BamfLegacyWindow *legacy_window); const char * (*get_class_name) (BamfLegacyWindow *legacy_window); const char * (*get_class_instance_name) (BamfLegacyWindow *legacy_window); const char * (*get_exec_string) (BamfLegacyWindow *legacy_window); const char * (*get_working_dir) (BamfLegacyWindow *legacy_window); char * (*save_mini_icon) (BamfLegacyWindow *legacy_window); char * (*get_process_name) (BamfLegacyWindow *legacy_window); char * (*get_app_id) (BamfLegacyWindow *legacy_window); char * (*get_unique_bus_name) (BamfLegacyWindow *legacy_window); char * (*get_menu_object_path) (BamfLegacyWindow *legacy_window); char * (*get_hint) (BamfLegacyWindow *legacy_window, const gchar *name); guint (*get_pid) (BamfLegacyWindow *legacy_window); guint32 (*get_xid) (BamfLegacyWindow *legacy_window); gboolean (*needs_attention) (BamfLegacyWindow *legacy_window); gboolean (*is_active) (BamfLegacyWindow *legacy_window); gboolean (*is_skip_tasklist) (BamfLegacyWindow *legacy_window); gboolean (*is_desktop) (BamfLegacyWindow *legacy_window); gboolean (*is_dialog) (BamfLegacyWindow *legacy_window); gboolean (*is_closed) (BamfLegacyWindow *legacy_window); BamfWindowMaximizationType (*maximized) (BamfLegacyWindow *legacy_window); BamfWindowType (*get_window_type) (BamfLegacyWindow *legacy_window); void (*get_geometry) (BamfLegacyWindow *legacy_window, gint *x, gint *y, gint *w, gint *h); void (*set_hint) (BamfLegacyWindow *legacy_window, const gchar *name, const gchar *value); GtkWidget * (*get_action_menu) (BamfLegacyWindow *legacy_window); void (*show_action_menu) (BamfLegacyWindow *legacy_window, guint32 time, guint button, gint x, gint y); void (*reopen) (BamfLegacyWindow *legacy_window); /*< signals >*/ void (*name_changed) (BamfLegacyWindow *legacy_window); void (*class_changed) (BamfLegacyWindow *legacy_window); void (*role_changed) (BamfLegacyWindow *legacy_window); void (*state_changed) (BamfLegacyWindow *legacy_window); void (*geometry_changed) (BamfLegacyWindow *legacy_window); void (*closed) (BamfLegacyWindow *legacy_window); }; struct _BamfLegacyWindow { GObject parent; /* private */ BamfLegacyWindowPrivate *priv; }; GType bamf_legacy_window_get_type (void) G_GNUC_CONST; guint32 bamf_legacy_window_get_xid (BamfLegacyWindow *self); guint bamf_legacy_window_get_pid (BamfLegacyWindow *self); void bamf_legacy_window_get_geometry (BamfLegacyWindow *self, gint *x, gint *y, gint *width, gint *height); gboolean bamf_legacy_window_is_active (BamfLegacyWindow *self); gboolean bamf_legacy_window_is_skip_tasklist (BamfLegacyWindow *self); gboolean bamf_legacy_window_needs_attention (BamfLegacyWindow *self); gboolean bamf_legacy_window_is_closed (BamfLegacyWindow *self); BamfWindowType bamf_legacy_window_get_window_type (BamfLegacyWindow *self); BamfWindowMaximizationType bamf_legacy_window_maximized (BamfLegacyWindow *self); const char * bamf_legacy_window_get_class_instance_name (BamfLegacyWindow *self); const char * bamf_legacy_window_get_class_name (BamfLegacyWindow *self); const char * bamf_legacy_window_get_name (BamfLegacyWindow *self); const char * bamf_legacy_window_get_role (BamfLegacyWindow *self); const char * bamf_legacy_window_get_exec_string (BamfLegacyWindow *self); const char * bamf_legacy_window_get_working_dir (BamfLegacyWindow *self); char * bamf_legacy_window_save_mini_icon (BamfLegacyWindow *self); GFile * bamf_legacy_window_get_saved_mini_icon (BamfLegacyWindow *self); char * bamf_legacy_window_get_process_name (BamfLegacyWindow *self); BamfLegacyWindow * bamf_legacy_window_get_transient (BamfLegacyWindow *self); char * bamf_legacy_window_get_hint (BamfLegacyWindow *self, const char *name); void bamf_legacy_window_set_hint (BamfLegacyWindow *self, const char *name, const char *value); gint bamf_legacy_window_get_stacking_position (BamfLegacyWindow *self); GtkWidget * bamf_legacy_window_get_action_menu (BamfLegacyWindow *self); void bamf_legacy_window_show_action_menu (BamfLegacyWindow *self, guint32 time, guint button, gint x, gint y); void bamf_legacy_window_reopen (BamfLegacyWindow *self); BamfLegacyWindow * bamf_legacy_window_new (WnckWindow *legacy_window); #endif ./src/bamf-daemon.h0000644000004100000410000000373214203512426014355 0ustar www-datawww-data/* * Copyright (C) 2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef __BAMFDAEMON_H__ #define __BAMFDAEMON_H__ #include #include #define BAMF_TYPE_DAEMON (bamf_daemon_get_type ()) #define BAMF_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_DAEMON, BamfDaemon)) #define BAMF_IS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_DAEMON)) #define BAMF_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_DAEMON, BamfDaemonClass)) #define BAMF_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_DAEMON)) #define BAMF_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_DAEMON, BamfDaemonClass)) typedef struct _BamfDaemon BamfDaemon; typedef struct _BamfDaemonClass BamfDaemonClass; typedef struct _BamfDaemonPrivate BamfDaemonPrivate; struct _BamfDaemonClass { GObjectClass parent; }; struct _BamfDaemon { GObject parent; /* private */ BamfDaemonPrivate *priv; }; GType bamf_daemon_get_type (void) G_GNUC_CONST; void bamf_daemon_start (BamfDaemon *self); void bamf_daemon_stop (BamfDaemon *self); gboolean bamf_daemon_is_running (BamfDaemon *self); BamfDaemon * bamf_daemon_get_default (void); #endif //__BAMFDAEMON_H__ ./src/bamf-legacy-screen.h0000644000004100000410000000720614203512426015633 0ustar www-datawww-data/* * Copyright (C) 2010 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * */ #ifndef __BAMFLEGACY_SCREEN_H__ #define __BAMFLEGACY_SCREEN_H__ #include "bamf-view.h" #include "bamf-legacy-window.h" #include #include #define BAMF_TYPE_LEGACY_SCREEN (bamf_legacy_screen_get_type ()) #define BAMF_LEGACY_SCREEN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_LEGACY_SCREEN, BamfLegacyScreen)) #define BAMF_IS_LEGACY_SCREEN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_LEGACY_SCREEN)) #define BAMF_LEGACY_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_LEGACY_SCREEN, BamfLegacyScreenClass)) #define BAMF_IS_LEGACY_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_LEGACY_SCREEN)) #define BAMF_LEGACY_SCREEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_LEGACY_SCREEN, BamfLegacyScreenClass)) #define BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENING "window-opening" #define BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENING_CANCELED "window-opening-canceled" #define BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENING_COMPLETED "window-opening-completed" #define BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENED "window-opened" #define BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_CLOSED "window-closed" #define BAMF_LEGACY_SCREEN_SIGNAL_STACKING_CHANGED "stacking-changed" #define BAMF_LEGACY_SCREEN_SIGNAL_ACTIVE_WINDOW_CHANGED "active-window-changed" typedef struct _BamfLegacyScreen BamfLegacyScreen; typedef struct _BamfLegacyScreenClass BamfLegacyScreenClass; typedef struct _BamfLegacyScreenPrivate BamfLegacyScreenPrivate; struct _BamfLegacyScreenClass { GObjectClass parent; GList (*get_windows) (BamfLegacyScreen *legacy_screen); /*< signals >*/ void (*window_opening) (BamfLegacyScreen *legacy_screen, const gchar *desktop_file); void (*window_opening_completed) (BamfLegacyScreen *legacy_screen, const gchar *desktop_file); void (*window_opening_canceled) (BamfLegacyScreen *legacy_screen, const gchar *desktop_file); void (*window_opened) (BamfLegacyScreen *legacy_screen, BamfLegacyWindow *legacy_window); void (*window_closed) (BamfLegacyScreen *legacy_screen, BamfLegacyWindow *legacy_window); void (*stacking_changed) (BamfLegacyScreen *legacy_screen); void (*active_window_changed) (BamfLegacyScreen *legacy_screen); }; struct _BamfLegacyScreen { GObject parent; /* private */ BamfLegacyScreenPrivate *priv; }; GType bamf_legacy_screen_get_type (void) G_GNUC_CONST; void bamf_legacy_screen_set_state_file (BamfLegacyScreen *screen, const char *file); GList * bamf_legacy_screen_get_windows (BamfLegacyScreen *screen); BamfLegacyWindow * bamf_legacy_screen_get_active_window (BamfLegacyScreen *screen); BamfLegacyScreen * bamf_legacy_screen_get_default (void); void bamf_legacy_screen_inject_window (BamfLegacyScreen *screen, guint xid); #endif ./src/bamf-matcher.c0000644000004100000410000026644714203512426014546 0ustar www-datawww-data/* * Copyright (C) 2010-2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include "config.h" #include "bamf-matcher.h" #include "bamf-matcher-private.h" #include "bamf-application.h" #include "bamf-tab.h" #include "bamf-window.h" #include "bamf-legacy-screen.h" #include #define BAMF_INDEX_NAME "bamf-2.index" #define EXEC_DESKTOP_FILE_OVERRIDE "--desktop_file_hint" #define ENV_DESKTOP_FILE_OVERRIDE "BAMF_DESKTOP_FILE_HINT" G_DEFINE_TYPE_WITH_PRIVATE (BamfMatcher, bamf_matcher, BAMF_DBUS_TYPE_MATCHER_SKELETON); enum { FAVORITES_CHANGED, LAST_SIGNAL, }; typedef enum { VIEW_ADDED = 0, VIEW_REMOVED } ViewChangeType; static BamfMatcher *static_matcher; static guint matcher_signals[LAST_SIGNAL] = { 0 }; // Prefixes to be ignored in exec strings const gchar* EXEC_BAD_PREFIXES[] = { "^gksu(do)?$", "^sudo$", "^su-to-root$", "^amdxdg-su$", "^java(ws)?$", "^cli$", "^mono$", "^ruby$", "^padsp$", "^aoss$", "^python(\\d(\\.\\d)?)?$", "^(ba)?sh$", "^perl$", "^env$", "^xdg-open$", "^qmlscene$", "^qmlviewer$", "^unity-webapps-runner$", "^webapp-container$", /* javaws strings: */ "^net\\.sourceforge\\.jnlp\\.runtime\\.Boot$", "^rt\\.jar$", "^com\\.sun\\.javaws\\.Main$", "^deploy\\.jar$" }; // Sufixes to be ignored in exec strings const gchar* EXEC_BAD_SUFIXES = "(\\.bin|\\.py|\\.pl|\\.qml)$"; // Prefixes that must be considered starting point of exec strings const gchar* EXEC_GOOD_PREFIXES[] = { "^unity-control-center$", "^libreoffice$", "^ooffice$", "^wine$", "^steam$", "^sol$" }; // These class names are ignored as matching values const gchar * CLASS_BAD_VALUES[] = { "sun-awt-X11-XFramePeer", "net-sourceforge-jnlp-runtime-Boot", "com-sun-javaws-Main", "VCLSalFrame" }; static void on_view_active_changed (BamfView *view, gboolean active, BamfMatcher *matcher) { BamfMatcherPrivate *priv; BamfView *last; g_return_if_fail (BAMF_IS_MATCHER (matcher)); g_return_if_fail (BAMF_IS_VIEW (view)); priv = matcher->priv; if (BAMF_IS_APPLICATION (view)) { /* Do some handy short circuiting so we can assume a signal * will be generated at the end of this */ if (!active && priv->active_app != view) return; if (active && priv->active_app == view) return; last = priv->active_app; if (active) priv->active_app = view; else priv->active_app = NULL; g_signal_emit_by_name (matcher, "active-application-changed", BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : "", BAMF_IS_VIEW (priv->active_app) ? bamf_view_get_path (BAMF_VIEW (priv->active_app)) : ""); } else if (BAMF_IS_WINDOW (view)) { /* Do some handy short circuiting so we can assume a signal * will be generated at the end of this */ if (!active && priv->active_win != view) return; if (active && priv->active_win == view) return; last = priv->active_win; if (active) priv->active_win = view; else priv->active_win = NULL; g_signal_emit_by_name (matcher, "active-window-changed", BAMF_IS_VIEW (last) ? bamf_view_get_path (BAMF_VIEW (last)) : "", BAMF_IS_VIEW (priv->active_win) ? bamf_view_get_path (BAMF_VIEW (priv->active_win)) : ""); } } static void bamf_matcher_unregister_view (BamfMatcher *self, BamfView *view); BamfApplication * bamf_matcher_get_application_by_desktop_file (BamfMatcher *self, const char *desktop_file) { GList *l; BamfView *view; g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); if (!desktop_file || desktop_file[0] == '\0') return NULL; for (l = self->priv->views; l; l = l->next) { view = l->data; if (!BAMF_IS_APPLICATION (view)) continue; BamfApplication *app = BAMF_APPLICATION (view); const gchar *app_desktop; app_desktop = bamf_application_get_desktop_file (app); if (g_strcmp0 (desktop_file, app_desktop) == 0) { return app; } } return NULL; } BamfApplication * bamf_matcher_get_application_by_xid (BamfMatcher *self, guint xid) { GList *l; BamfView *view; g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); for (l = self->priv->views; l; l = l->next) { view = l->data; if (!BAMF_IS_APPLICATION (view)) continue; if (bamf_application_manages_xid (BAMF_APPLICATION (view), xid)) { return BAMF_APPLICATION (view); } } return NULL; } BamfView * bamf_matcher_get_view_by_path (BamfMatcher *self, const char *view_path) { GList *l; BamfView *view; g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); for (l = self->priv->views; l; l = l->next) { view = l->data; if (!BAMF_IS_VIEW (view)) continue; if (g_strcmp0 (bamf_view_get_path (view), view_path) == 0) { return view; } } return NULL; } static gboolean emit_paths_changed (gpointer user_data) { BamfMatcher *matcher; BamfMatcherPrivate *priv; GHashTableIter iter; guint ht_size; ViewChangeType change_type; gpointer key, value; gchar **opened_apps, **closed_apps; gint i, j; g_return_val_if_fail (BAMF_IS_MATCHER (user_data), FALSE); matcher = (BamfMatcher*) user_data; priv = matcher->priv; ht_size = g_hash_table_size (priv->opened_closed_paths_table); /* these will end with NULL pointer */ opened_apps = g_new0 (gchar*, ht_size+1); closed_apps = g_new0 (gchar*, ht_size+1); i = 0; j = 0; g_hash_table_iter_init (&iter, priv->opened_closed_paths_table); while (g_hash_table_iter_next (&iter, &key, &value)) { change_type = (ViewChangeType) GPOINTER_TO_UINT (value); if (change_type == VIEW_ADDED) opened_apps[i++] = (gchar*) key; else closed_apps[j++] = (gchar*) key; } /* the strings are owned by the hashtable, so emit the signal and clear * the hashtable then */ g_signal_emit_by_name (matcher, "running-applications-changed", opened_apps, closed_apps); g_hash_table_remove_all (priv->opened_closed_paths_table); g_free (closed_apps); g_free (opened_apps); priv->dispatch_changes_id = 0; return FALSE; } static void bamf_matcher_prepare_path_change (BamfMatcher *self, const gchar *desktop_file, ViewChangeType change_type) { BamfMatcherPrivate *priv; BamfApplication *app; if (desktop_file == NULL) return; g_return_if_fail (BAMF_IS_MATCHER (self)); priv = self->priv; /* the app was already running (ADDED) / had more instances which are still * there (REMOVED) */ app = bamf_matcher_get_application_by_desktop_file (self, desktop_file); if (BAMF_IS_APPLICATION (app) && bamf_view_is_running (BAMF_VIEW (app))) { return; } if (!priv->opened_closed_paths_table) { priv->opened_closed_paths_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); } g_hash_table_insert (priv->opened_closed_paths_table, g_strdup (desktop_file), GUINT_TO_POINTER (change_type)); if (priv->dispatch_changes_id == 0) { priv->dispatch_changes_id = g_timeout_add (500, emit_paths_changed, self); } } static gboolean bamf_matcher_is_view_registered (BamfMatcher *self, BamfView *view) { g_return_val_if_fail (BAMF_IS_MATCHER (self), FALSE); g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); /* Instead of looping over the self->priv->views list, we can safely assume * that if a view is not registered then its path is NULL */ return (bamf_view_get_path (view) != NULL); } static void bamf_matcher_register_view_stealing_ref (BamfMatcher *self, BamfView *view) { const char *path, *type; GDBusConnection *connection; GDBusInterfaceSkeleton *dbus_interface = G_DBUS_INTERFACE_SKELETON (self); connection = g_dbus_interface_skeleton_get_connection (dbus_interface); path = bamf_view_export_on_bus (view, connection); type = bamf_view_get_view_type (view); g_signal_connect_swapped (G_OBJECT (view), "closed-internal", (GCallback) bamf_matcher_unregister_view, self); g_signal_connect (G_OBJECT (view), "active-changed", (GCallback) on_view_active_changed, self); if (BAMF_IS_APPLICATION (view)) { bamf_matcher_prepare_path_change (self, bamf_application_get_desktop_file (BAMF_APPLICATION (view)), VIEW_ADDED); } // This steals the reference of the view self->priv->views = g_list_prepend (self->priv->views, view); g_signal_emit_by_name (self, "view-opened", path, type); // trigger manually since this is already active if (bamf_view_is_active (view)) on_view_active_changed (view, TRUE, self); } static void bamf_matcher_unregister_view (BamfMatcher *self, BamfView *view) { const char * path; const char * type; path = bamf_view_get_path (view); type = bamf_view_get_view_type (view); g_signal_emit_by_name (self, "view-closed", path, type); g_signal_handlers_disconnect_by_data (G_OBJECT (view), self); if (BAMF_IS_APPLICATION (view)) { bamf_matcher_prepare_path_change (self, bamf_application_get_desktop_file (BAMF_APPLICATION (view)), VIEW_REMOVED); } if (self->priv->active_app == view) self->priv->active_app = NULL; if (self->priv->active_win == view) self->priv->active_win = NULL; GList *listed_view = g_list_find (self->priv->views, view); if (listed_view) { self->priv->views = g_list_delete_link (self->priv->views, listed_view); g_object_unref (view); } } gboolean bamf_matcher_is_valid_process_prefix (BamfMatcher *self, const char *process_name) { GRegex *regex; gint i; g_return_val_if_fail (BAMF_IS_MATCHER (self), TRUE); if (!process_name || *process_name == '\0') return FALSE; for (i = 0; i < self->priv->bad_prefixes->len; ++i) { regex = g_array_index (self->priv->bad_prefixes, GRegex *, i); if (g_regex_match (regex, process_name, 0, NULL)) { return FALSE; } } return TRUE; } /* Attempts to return the binary name for a particular execution string */ char * bamf_matcher_get_trimmed_exec (BamfMatcher * self, const char * exec_string) { gchar *result = NULL, *part, *tmp; gchar **parts; gint i, j, parts_size; gboolean bad_prefix; gboolean good_prefix = FALSE; gboolean double_parsed = FALSE; GRegex *regex; if (!exec_string || exec_string[0] == '\0') return NULL; if (!g_shell_parse_argv (exec_string, &parts_size, &parts, NULL)) return g_strdup (exec_string); for (i = 0; i < parts_size; ++i) { part = parts[i]; if (*part == '%' || *part == '$' || g_utf8_strrchr (part, -1, '=')) continue; if (i+1 < parts_size && g_strcmp0 (parts[i], EXEC_DESKTOP_FILE_OVERRIDE) == 0) { /* Skip if the .desktop file is overridden using the exec parameter */ ++i; continue; } if (*part != '-' || good_prefix) { if (!result) { tmp = g_utf8_strrchr (part, -1, G_DIR_SEPARATOR); if (tmp) part = tmp + 1; } if (good_prefix) { tmp = g_strconcat (result, " ", part, NULL); g_free (result); result = tmp; } else { for (j = 0; j < self->priv->good_prefixes->len; j++) { regex = g_array_index (self->priv->good_prefixes, GRegex *, j); if (g_regex_match (regex, part, 0, NULL)) { good_prefix = TRUE; result = g_ascii_strdown (part, -1); break; } } if (good_prefix) continue; bad_prefix = !bamf_matcher_is_valid_process_prefix (self, part); if (!bad_prefix) { if (!double_parsed && g_utf8_strrchr (part, -1, ' ')) { /* If the current exec_string has an empty char, * we double check it again to parse scripts: * For example strings like 'sh -c "foo || bar"' */ gchar **old_parts = parts; if (g_shell_parse_argv (part, &parts_size, &parts, NULL)) { // Make the loop to restart! g_strfreev (old_parts); i = -1; continue; } double_parsed = TRUE; } result = g_ascii_strdown (part, -1); break; } } } } if (!result) { if (parts_size > 0) { tmp = g_utf8_strrchr (parts[0], -1, G_DIR_SEPARATOR); if (tmp) exec_string = tmp + 1; } result = g_strdup (exec_string); } else { tmp = result; regex = g_regex_new (EXEC_BAD_SUFIXES, 0, 0, NULL); result = g_regex_replace_literal (regex, result, -1, 0, "", 0, NULL); g_free (tmp); g_regex_unref (regex); } g_strfreev (parts); return result; } char * get_exec_overridden_desktop_file (const char *exec_string) { gchar *result = NULL; gchar **parts; gint i, parts_size; if (!exec_string || exec_string[0] == '\0') return result; if (!g_shell_parse_argv (exec_string, &parts_size, &parts, NULL)) return result; for (i = 0; i < parts_size; ++i) { if (i+1 < parts_size && g_strcmp0 (parts[i], EXEC_DESKTOP_FILE_OVERRIDE) == 0) { if (g_str_has_suffix (parts[i+1], ".desktop") && g_file_test (parts[i+1], G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR)) { result = g_strdup (parts[i+1]); break; } } } g_strfreev (parts); return result; } static char * get_env_overridden_desktop_file (guint pid) { gchar *environ_file; gchar *environ; gchar *result; gsize file_len; gint i; if (pid < 2) return NULL; environ = NULL; result = NULL; environ_file = g_strdup_printf ("/proc/%u/environ", pid); if (g_file_get_contents (environ_file, &environ, &file_len, NULL)) { for (i = 0; i < file_len && environ && environ[i] != '\0'; i += strlen (environ + i) + 1) { const gchar *var = environ + i; if (g_str_has_prefix (var, ENV_DESKTOP_FILE_OVERRIDE"=")) { const gchar *file_path; file_path = var + sizeof (ENV_DESKTOP_FILE_OVERRIDE); if (g_str_has_suffix (file_path, ".desktop") && g_file_test (file_path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR)) { result = g_strdup (file_path); break; } } } } g_free (environ); g_free (environ_file); return result; } static GList * pid_parent_tree (BamfMatcher *self, guint pid) { BamfMatcherPrivate *priv; GList *tree, *l; guint known_pid; g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); priv = self->priv; tree = g_list_append (NULL, GUINT_TO_POINTER (pid)); glibtop_proc_uid buf; glibtop_get_proc_uid (&buf, pid); pid = buf.ppid; while (pid > 1) { for (l = priv->known_pids; l; l = l->next) { /* ensure we dont match onto a terminal by mistake */ known_pid = GPOINTER_TO_UINT (l->data); if (known_pid == pid) return tree; } tree = g_list_prepend (tree, GUINT_TO_POINTER (pid)); glibtop_proc_uid buf; glibtop_get_proc_uid (&buf, pid); pid = buf.ppid; } return g_list_reverse (tree); } static gboolean is_desktop_folder_item (const char *desktop_file_path, gssize max_len) { gsize len; const char *desktop_folder; g_return_val_if_fail (desktop_file_path, FALSE); if (max_len > 0) { len = max_len; } else { char *tmp; tmp = strrchr (desktop_file_path, G_DIR_SEPARATOR); g_return_val_if_fail (tmp, FALSE); len = tmp - desktop_file_path; } desktop_folder = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP); if (strncmp (desktop_folder, desktop_file_path, len) == 0) return TRUE; return FALSE; } static gboolean is_no_display_desktop (BamfMatcher *self, const gchar *desktop_path) { g_return_val_if_fail (BAMF_IS_MATCHER (self), FALSE); if (!desktop_path || desktop_path[0] == '\0') return FALSE; GList *list = self->priv->no_display_desktop; return g_list_find_custom (list, desktop_path, (GCompareFunc) g_strcmp0) != NULL; } static GList * get_last_no_display_desktop_in_list (BamfMatcher *self, GList *desktop_list) { GList *last, *l; g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); last = NULL; for (l = desktop_list; l; l = l->next) { char *desktop_path = l->data; if (is_no_display_desktop (self, desktop_path)) { last = l; break; } } return last; } static void insert_data_into_tables (BamfMatcher *self, const char *data, const char *exec, const char *desktop_id, gboolean no_display, GHashTable *desktop_file_table, GHashTable *desktop_id_table) { GList *file_list, *id_list, *last, *l; char *datadup; g_return_if_fail (exec); g_return_if_fail (desktop_id); file_list = g_hash_table_lookup (desktop_file_table, exec); id_list = g_hash_table_lookup (desktop_id_table, desktop_id); if (g_list_find_custom (file_list, data, (GCompareFunc) g_strcmp0) && g_list_find_custom (id_list, data, (GCompareFunc) g_strcmp0)) { return; } datadup = g_strdup (data); if (no_display) { self->priv->no_display_desktop = g_list_prepend (self->priv->no_display_desktop, datadup); } /* order so that items whose desktop_id == exec string are first in the list */ if (g_strcmp0 (exec, desktop_id) == 0 || is_desktop_folder_item (datadup, -1)) { last = NULL; for (l = file_list; l; l = l->next) { char *dpath; char *dname_start, *dname_end; size_t len; dpath = l->data; dname_start = strrchr (dpath, G_DIR_SEPARATOR); if (!dname_start) { continue; } dname_start++; dname_end = strrchr (dname_start, '.'); len = dname_end - dname_start; if (!dname_end || len < 1) { continue; } if ((strncmp (desktop_id, dname_start, len) != 0 || is_no_display_desktop (self, dpath)) && !is_desktop_folder_item (dpath, (dname_start - dpath - 1))) { last = l; break; } } file_list = g_list_insert_before (file_list, last, datadup); } else { last = NULL; if (!no_display) last = get_last_no_display_desktop_in_list (self, file_list); file_list = g_list_insert_before (file_list, last, datadup); } last = NULL; if (!no_display) last = get_last_no_display_desktop_in_list (self, id_list); id_list = g_list_insert_before (id_list, last, datadup); g_hash_table_insert (desktop_file_table, g_strdup (exec), file_list); g_hash_table_insert (desktop_id_table, g_strdup (desktop_id), id_list); } static void insert_desktop_file_class_into_table (BamfMatcher *self, const char *desktop_file, GHashTable *desktop_class_table) { GKeyFile *desktop_keyfile; char *class; g_return_if_fail (desktop_file); desktop_keyfile = g_key_file_new (); if (g_key_file_load_from_file (desktop_keyfile, desktop_file, G_KEY_FILE_NONE, NULL)) { class = g_key_file_get_string (desktop_keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS, NULL); if (class) g_hash_table_insert (desktop_class_table, g_strdup (desktop_file), class); g_key_file_free (desktop_keyfile); } } static void load_desktop_file_to_table (BamfMatcher * self, const char *file, GHashTable *desktop_file_table, GHashTable *desktop_id_table, GHashTable *desktop_class_table) { GDesktopAppInfo *desktop_file; gboolean no_display; char *exec; char *path; GString *desktop_id; /* is ok... really */ g_return_if_fail (BAMF_IS_MATCHER (self)); desktop_file = g_desktop_app_info_new_from_filename (file); if (!G_IS_APP_INFO (desktop_file)) { return; } if (!g_desktop_app_info_get_show_in (desktop_file, NULL)) { g_object_unref (desktop_file); return; } exec = g_strdup (g_app_info_get_commandline (G_APP_INFO (desktop_file))); if (!exec || exec[0] == '\0') { g_object_unref (desktop_file); if (exec) { g_free (exec); } return; } /** * Set of nasty hacks which should be removed some day. We wish to keep the full exec * strings so we can do nasty matching hacks later. A very very evil thing indeed. However this * helps hack around applications that run in the same process cross radically different instances. * A better solution needs to be thought up, however at this time it is not known. **/ char *tmp = bamf_matcher_get_trimmed_exec (self, exec); g_free (exec); exec = tmp; path = g_path_get_basename (file); desktop_id = g_string_new (path); g_free (path); desktop_id = g_string_truncate (desktop_id, desktop_id->len - 8); /* remove last 8 characters for .desktop */ no_display = g_desktop_app_info_get_nodisplay (desktop_file); insert_data_into_tables (self, file, exec, desktop_id->str, no_display, desktop_file_table, desktop_id_table); insert_desktop_file_class_into_table (self, file, desktop_class_table); g_free (exec); g_string_free (desktop_id, TRUE); g_object_unref (desktop_file); } static void load_directory_to_table (BamfMatcher * self, const char *directory, GHashTable *desktop_file_table, GHashTable *desktop_id_table, GHashTable *desktop_class_table) { GFile *dir; GFileEnumerator *enumerator; GFileInfo *info; const char *name; char *path; dir = g_file_new_for_path (directory); enumerator = g_file_enumerate_children (dir, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL); if (!enumerator) return; info = g_file_enumerator_next_file (enumerator, NULL, NULL); for (; info; info = g_file_enumerator_next_file (enumerator, NULL, NULL)) { name = g_file_info_get_name (info); path = g_build_filename (directory, name, NULL); if (g_str_has_suffix (name, ".desktop")) load_desktop_file_to_table (self, path, desktop_file_table, desktop_id_table, desktop_class_table); g_free (path); g_object_unref (info); } g_object_unref (enumerator); g_object_unref (dir); } static void load_index_file_to_table (BamfMatcher * self, const char *index_file, GHashTable *desktop_file_table, GHashTable *desktop_id_table, GHashTable *desktop_class_table) { GFile *file; GFileInputStream *stream; GDataInputStream *input; char *line; char *directory; gchar **current_desktops = NULL; const gchar *xdg_current_desktop; gsize length; file = g_file_new_for_path (index_file); g_return_if_fail (file); stream = g_file_read (file, NULL, NULL); if (!stream) { g_object_unref (file); return; } length = 0; xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); if (xdg_current_desktop) current_desktops = g_strsplit (xdg_current_desktop, ":", 0); directory = g_path_get_dirname (index_file); input = g_data_input_stream_new (G_INPUT_STREAM (stream)); while ((line = g_data_input_stream_read_line (input, &length, NULL, NULL))) { char *exec; char *filename; const char *class; const char *show_in; GString *desktop_id; gboolean no_display; /* Order is: 0 Desktop-Id, 1 Exec, 2 class, 3 ShowIn, 4 NoDisplay */ gchar **parts = g_strsplit (line, "\t", 5); show_in = parts[3]; if (current_desktops && show_in && show_in[0] != '\0') { gchar **sub_parts = g_strsplit (show_in, ";", -1); gboolean found_current = FALSE; int i = 0; for (i = 0; sub_parts[i]; ++i) { if (g_strv_contains ((const gchar * const *) current_desktops, sub_parts[i]) == 0) { found_current = TRUE; break; } } g_strfreev (sub_parts); if (!found_current) { length = 0; g_strfreev (parts); continue; } } char *tmp = bamf_matcher_get_trimmed_exec (self, parts[1]); g_free (parts[1]); parts[1] = tmp; exec = parts[1]; filename = g_build_filename (directory, parts[0], NULL); desktop_id = g_string_new (parts[0]); g_string_truncate (desktop_id, desktop_id->len - 8); no_display = FALSE; if (parts[4] && g_ascii_strcasecmp (parts[4], "true") == 0) { no_display = TRUE; } insert_data_into_tables (self, filename, exec, desktop_id->str, no_display, desktop_file_table, desktop_id_table); class = parts[2]; if (class && class[0] != '\0') { g_hash_table_insert (desktop_class_table, g_strdup (filename), g_strdup (class)); } g_string_free (desktop_id, TRUE); g_free (line); g_free (filename); g_strfreev (parts); length = 0; } g_object_unref (input); g_object_unref (stream); g_object_unref (file); g_strfreev (current_desktops); g_free (directory); } static GList * get_directory_tree_list (GList *) G_GNUC_WARN_UNUSED_RESULT; static GList * get_directory_tree_list (GList *dirs) { GList *l; GFile *file; GFileEnumerator *enumerator; GFileInfo *info; gchar *path, *subpath; for (l = dirs; l; l = l->next) { path = l->data; file = g_file_new_for_path (path); if (!g_file_query_exists (file, NULL)) { g_object_unref (file); continue; } enumerator = g_file_enumerate_children (file, "standard::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL); if (!enumerator) continue; info = g_file_enumerator_next_file (enumerator, NULL, NULL); while (info) { if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) { /* append after the current list item for non-recursive recursion love * and to keep the priorities (hierarchy) of the .desktop directories. */ subpath = g_build_filename (path, g_file_info_get_name (info), NULL); dirs = g_list_insert_before (dirs, l->next, subpath); } g_object_unref (info); info = g_file_enumerator_next_file (enumerator, NULL, NULL); } g_object_unref (enumerator); g_object_unref (file); } return dirs; } static GList * list_prepend_desktop_file_env_directories (GList *, const gchar *) G_GNUC_WARN_UNUSED_RESULT; static GList * list_prepend_desktop_file_env_directories (GList *dirs, const gchar *varname) { g_return_val_if_fail (varname, dirs); const gchar *env; char *path; char **data_dirs = NULL; char **data; env = g_getenv (varname); if (env) { data_dirs = g_strsplit (env, ":", 0); for (data = data_dirs; data && *data; data++) { path = g_build_filename (*data, "applications", NULL); if (g_file_test (path, G_FILE_TEST_IS_DIR) && !g_list_find_custom (dirs, path, (GCompareFunc) g_strcmp0)) { dirs = g_list_prepend (dirs, path); } else { g_free (path); } } if (data_dirs) g_strfreev (data_dirs); } return dirs; } static GList * get_desktop_file_directories (BamfMatcher *self) { GList *dirs = NULL; char *path; dirs = list_prepend_desktop_file_env_directories (dirs, "XDG_DATA_DIRS"); if (!g_list_find_custom (dirs, "/usr/share/applications", (GCompareFunc) g_strcmp0)) dirs = g_list_prepend (dirs, g_strdup ("/usr/share/applications")); if (!g_list_find_custom (dirs, "/usr/local/share/applications", (GCompareFunc) g_strcmp0)) dirs = g_list_prepend (dirs, g_strdup ("/usr/local/share/applications")); dirs = list_prepend_desktop_file_env_directories (dirs, "XDG_DATA_HOME"); /* If XDG_DATA_HOME doesn't exist, we need to track .local or the home itself! */ path = g_build_filename (g_get_home_dir (), ".local/share/applications", NULL); if (!g_list_find_custom (dirs, path, (GCompareFunc) g_strcmp0)) dirs = g_list_prepend (dirs, path); else g_free (path); /* include subdirs */ dirs = get_directory_tree_list (dirs); /* Include also the user desktop folder, but without its subfolders */ dirs = g_list_prepend (dirs, g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP))); return dirs; } static gint compare_sub_values (gconstpointer desktop_path, gconstpointer desktop_file) { return !g_str_has_prefix (desktop_file, desktop_path); } static void hash_table_remove_sub_values (GHashTable *htable, GCompareFunc compare_func, GFreeFunc free_func, gpointer target, gboolean search_all) { g_return_if_fail (htable); g_return_if_fail (compare_func); GHashTableIter iter; gpointer key; gpointer value; g_hash_table_iter_init (&iter, htable); while (g_hash_table_iter_next (&iter, &key, &value)) { GList *list, *l; gboolean found; list = value; found = FALSE; l = list; while (l) { GList *next = l->next; if (compare_func (target, l->data) == 0) { found = TRUE; if (!l->prev && !l->next) { if (free_func) g_list_free_full (list, free_func); else g_list_free (list); g_hash_table_iter_remove (&iter); next = NULL; break; } else { if (free_func) free_func (l->data); /* If the target is the first element of the list (and thanks to * the previous check we're also sure that it's not the only one), * simply switch it with its follower, not to change the first * pointer and the hash table value for key */ if (l == list) { l->data = next->data; l = next; next = list; } list = g_list_delete_link (list, l); } if (!search_all) break; } l = next; } if (found && !search_all) break; } } static gboolean hash_table_compare_sub_values (gpointer desktop_path, gpointer desktop_class, gpointer target_path) { return !compare_sub_values (target_path, desktop_path); } static void fill_desktop_file_table (BamfMatcher *, GList *, GHashTable *, GHashTable *, GHashTable *); static void on_monitor_changed (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent type, BamfMatcher *self) { char *path; const char *monitored_dir; GFileType filetype; g_return_if_fail (G_IS_FILE_MONITOR (monitor)); g_return_if_fail (G_IS_FILE (file)); g_return_if_fail (BAMF_IS_MATCHER (self)); if (type != G_FILE_MONITOR_EVENT_CREATED && type != G_FILE_MONITOR_EVENT_DELETED && type != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT) return; path = g_file_get_path (file); filetype = g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL); monitored_dir = g_object_get_data (G_OBJECT (monitor), "root"); if (!g_str_has_suffix (path, ".desktop") && filetype != G_FILE_TYPE_DIRECTORY && type != G_FILE_MONITOR_EVENT_DELETED) { g_free(path); return; } if (type == G_FILE_MONITOR_EVENT_DELETED || type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT) { if (g_str_has_suffix (path, ".desktop")) { /* Remove all the .desktop file references from the hash tables. * Free the string itself only on the 2nd pass (tables share the same * string instance) */ hash_table_remove_sub_values (self->priv->desktop_id_table, (GCompareFunc) g_strcmp0, NULL, path, FALSE); hash_table_remove_sub_values (self->priv->desktop_file_table, (GCompareFunc) g_strcmp0, g_free, path, FALSE); g_hash_table_remove (self->priv->desktop_class_table, path); } else if (g_strcmp0 (monitored_dir, path) == 0) { /* Remove all the references to the .desktop files placed in subfolders * of the current path. Free the strings itself only on the 2nd pass * (as before, the tables share the same string instance) */ char *prefix = g_strconcat (path, G_DIR_SEPARATOR_S, NULL); hash_table_remove_sub_values (self->priv->desktop_id_table, compare_sub_values, NULL, prefix, TRUE); hash_table_remove_sub_values (self->priv->desktop_file_table, compare_sub_values, g_free, prefix, TRUE); g_hash_table_foreach_remove (self->priv->desktop_class_table, hash_table_compare_sub_values, prefix); g_signal_handlers_disconnect_by_func (monitor, on_monitor_changed, self); self->priv->monitors = g_list_remove (self->priv->monitors, monitor); g_object_unref (monitor); g_free (prefix); } } if (type == G_FILE_MONITOR_EVENT_CREATED || type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT) { if (filetype == G_FILE_TYPE_DIRECTORY) { const char *desktop_dir; desktop_dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP); if (g_strcmp0 (monitored_dir, desktop_dir) != 0) { GList *dirs = NULL; dirs = g_list_prepend (dirs, g_strdup (path)); dirs = get_directory_tree_list (dirs); fill_desktop_file_table (self, dirs, self->priv->desktop_file_table, self->priv->desktop_id_table, self->priv->desktop_class_table); g_list_free_full (dirs, g_free); } } else if (filetype != G_FILE_TYPE_UNKNOWN) { bamf_matcher_load_desktop_file (self, path); } } g_free (path); } static void bamf_matcher_add_new_monitored_directory (BamfMatcher * self, const gchar *directory) { g_return_if_fail (BAMF_IS_MATCHER (self)); GFile *file; GFileMonitor *monitor; GError *error = NULL; file = g_file_new_for_path (directory); monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, &error); if (error) { g_message ("Error monitoring %s: %s\n", directory, error->message); g_error_free (error); g_object_unref (file); return; } g_file_monitor_set_rate_limit (monitor, 1000); g_object_set_data_full (G_OBJECT (monitor), "root", g_strdup (directory), g_free); g_signal_connect (monitor, "changed", (GCallback) on_monitor_changed, self); self->priv->monitors = g_list_prepend (self->priv->monitors, monitor); g_object_unref (file); } static void fill_desktop_file_table (BamfMatcher * self, GList *directories, GHashTable *desktop_file_table, GHashTable *desktop_id_table, GHashTable *desktop_class_table) { g_return_if_fail (BAMF_IS_MATCHER (self)); GList *l; char *directory; char *bamf_file; for (l = directories; l; l = l->next) { directory = l->data; if (!g_file_test (directory, G_FILE_TEST_IS_DIR)) continue; bamf_matcher_add_new_monitored_directory (self, directory); bamf_file = g_build_filename (directory, BAMF_INDEX_NAME, NULL); if (g_file_test (bamf_file, G_FILE_TEST_EXISTS)) { load_index_file_to_table (self, bamf_file, desktop_file_table, desktop_id_table, desktop_class_table); } else { load_directory_to_table (self, directory, desktop_file_table, desktop_id_table, desktop_class_table); } g_free (bamf_file); } } static void create_desktop_file_table (BamfMatcher * self, GHashTable **desktop_file_table, GHashTable **desktop_id_table, GHashTable **desktop_class_table) { g_return_if_fail (BAMF_IS_MATCHER (self)); GList *directories; *desktop_file_table = g_hash_table_new_full ((GHashFunc) g_str_hash, (GEqualFunc) g_str_equal, (GDestroyNotify) g_free, NULL); *desktop_id_table = g_hash_table_new_full ((GHashFunc) g_str_hash, (GEqualFunc) g_str_equal, (GDestroyNotify) g_free, NULL); *desktop_class_table = g_hash_table_new_full ((GHashFunc) g_str_hash, (GEqualFunc) g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_free); directories = get_desktop_file_directories (self); fill_desktop_file_table (self, directories, *desktop_file_table, *desktop_id_table, *desktop_class_table); g_list_free_full (directories, g_free); } static GList * bamf_matcher_possible_applications_for_window_process (BamfMatcher *self, BamfLegacyWindow *window) { BamfMatcherPrivate *priv; GList *result = NULL, *table_list, *l; const char *exec_string; char *trimmed; g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (window), NULL); priv = self->priv; exec_string = bamf_legacy_window_get_exec_string (window); if (exec_string) { trimmed = bamf_matcher_get_trimmed_exec (self, exec_string); if (trimmed) { if (trimmed[0] != '\0') { table_list = g_hash_table_lookup (priv->desktop_file_table, trimmed); for (l = table_list; l; l = l->next) { result = g_list_prepend (result, g_strdup (l->data)); } } g_free (trimmed); } } if (result) { result = g_list_reverse (result); return result; } gchar *proc_name = bamf_legacy_window_get_process_name (window); if (bamf_matcher_is_valid_process_prefix (self, proc_name)) { table_list = g_hash_table_lookup (priv->desktop_file_table, proc_name); for (l = table_list; l; l = l->next) { result = g_list_prepend (result, g_strdup (l->data)); } } g_free (proc_name); result = g_list_reverse (result); return result; } static gboolean is_libreoffice_window (BamfLegacyWindow * window) { const char *class_name = bamf_legacy_window_get_class_name (window); if (!class_name) return FALSE; return (g_ascii_strncasecmp (class_name, "libreoffice", 11) == 0 || g_ascii_strncasecmp (class_name, "openoffice", 10) == 0); } static gboolean is_web_app_window (BamfLegacyWindow *window) { const char *window_class = bamf_legacy_window_get_class_name (window); const char *instance_name = bamf_legacy_window_get_class_instance_name (window); // Chrome/Chromium uses url wm_class strings to represent its web apps (--app mode). // These apps will still have the same parent pid and hints as the main chrome // window, so we skip the hint check. // We can tell a window is a chrome web app window if its instance name is // not google-chrome but its window class is Google-chrome // We can tell a window is chromium web app window if its instance name is // not chromium-browser but its window class is Chromium Browser gboolean valid_app = FALSE; if (instance_name && window_class) { if (g_strcmp0 (window_class, "Google-chrome") == 0 && g_strcmp0 (instance_name, "google-chrome") != 0 && !g_str_has_prefix (instance_name, "Google-chrome")) { valid_app = TRUE; } else if (g_strcmp0 (window_class, "Chromium-browser") == 0 && g_strcmp0 (instance_name, "chromium-browser") != 0 && !g_str_has_prefix (instance_name, "Chromium-browser")) { valid_app = TRUE; } } return valid_app; } static gboolean is_javaws_window (BamfLegacyWindow *window) { const char *window_class = bamf_legacy_window_get_class_name (window); if (g_strcmp0 (window_class, "net-sourceforge-jnlp-runtime-Boot") == 0 || g_strcmp0 (window_class, "com-sun-javaws-Main") == 0) { return TRUE; } return FALSE; } static gboolean bamf_matcher_window_skips_hint_set (BamfMatcher *self, BamfLegacyWindow *window) { gboolean skip_hint_set; g_return_val_if_fail (BAMF_IS_MATCHER (self), TRUE); skip_hint_set = is_libreoffice_window (window) || is_web_app_window (window) || is_javaws_window (window); return skip_hint_set; } static GList * bamf_matcher_get_class_matching_desktop_files (BamfMatcher *self, const gchar *class_name) { GList* desktop_files = NULL; gpointer key; gpointer value; GHashTableIter iter; g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); g_hash_table_iter_init (&iter, self->priv->desktop_class_table); while (g_hash_table_iter_next (&iter, &key, &value)) { gchar* desktop_file = g_strdup (key); gchar* desktop_class = value; if (g_strcmp0 (desktop_class, class_name) == 0) { desktop_files = g_list_prepend (desktop_files, desktop_file); } } return desktop_files; } static gboolean bamf_matcher_has_instance_class_desktop_file (BamfMatcher *self, const gchar *class_name) { gpointer key; gpointer value; GHashTableIter iter; g_return_val_if_fail (BAMF_IS_MATCHER (self), FALSE); g_hash_table_iter_init (&iter, self->priv->desktop_class_table); while (g_hash_table_iter_next (&iter, &key, &value)) { gchar* desktop_class = value; if (g_strcmp0 (desktop_class, class_name) == 0) { return TRUE; } } return FALSE; } gboolean bamf_matcher_is_valid_class_name (BamfMatcher *self, const char *class_name) { int i; g_return_val_if_fail (BAMF_IS_MATCHER (self), FALSE); if (!class_name) return TRUE; for (i = 0; i < G_N_ELEMENTS (CLASS_BAD_VALUES); ++i) { if (g_strcmp0 (class_name, CLASS_BAD_VALUES[i]) == 0) return FALSE; } return TRUE; } static GList * bamf_matcher_possible_applications_for_window (BamfMatcher *self, BamfWindow *bamf_window, const char **target_class_out) { BamfMatcherPrivate *priv; BamfLegacyWindow *window; GList *desktop_files = NULL, *l; char *app_id; char *desktop_file = NULL; const char *desktop_class = NULL; const char *class_name = NULL; const char *instance_name = NULL; const char *target_class = NULL; gboolean filter_by_wmclass = FALSE; g_return_val_if_fail (BAMF_IS_WINDOW (bamf_window), NULL); g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); priv = self->priv; window = bamf_window_get_window (bamf_window); desktop_file = bamf_legacy_window_get_hint (window, _BAMF_DESKTOP_FILE); class_name = bamf_legacy_window_get_class_name (window); instance_name = bamf_legacy_window_get_class_instance_name (window); if (!bamf_matcher_is_valid_class_name (self, class_name)) class_name = NULL; if (!bamf_matcher_is_valid_class_name (self, instance_name)) instance_name = NULL; target_class = instance_name; filter_by_wmclass = bamf_matcher_has_instance_class_desktop_file (self, target_class); if (!filter_by_wmclass) { if (is_web_app_window (window)) { // This ensures that a new application is created even for unknown webapps filter_by_wmclass = TRUE; } else { target_class = class_name; filter_by_wmclass = bamf_matcher_has_instance_class_desktop_file (self, target_class); } } if (desktop_file) { desktop_class = bamf_matcher_get_desktop_file_class (self, desktop_file); if ((!filter_by_wmclass && !desktop_class) || g_strcmp0 (desktop_class, target_class) == 0) { desktop_files = g_list_prepend (desktop_files, desktop_file); } else { g_free (desktop_file); } } if (!desktop_files) { gint pid = bamf_legacy_window_get_pid (window); desktop_file = get_env_overridden_desktop_file (pid); if (desktop_file) { desktop_files = g_list_prepend (desktop_files, desktop_file); } const char *exec_string = bamf_legacy_window_get_exec_string (window); desktop_file = get_exec_overridden_desktop_file (exec_string); if (desktop_file) { desktop_files = g_list_prepend (desktop_files, desktop_file); } if (!desktop_files) { app_id = bamf_window_get_application_id (bamf_window); if (app_id) { for (l = g_hash_table_lookup (priv->desktop_id_table, app_id); l; l = l->next) { desktop_file = l->data; desktop_class = bamf_matcher_get_desktop_file_class (self, desktop_file); if ((!filter_by_wmclass && !desktop_class) || g_strcmp0 (desktop_class, target_class) == 0) { desktop_files = g_list_prepend (desktop_files, g_strdup (desktop_file)); } } g_free (app_id); } } } desktop_file = NULL; if (!desktop_files) { if (class_name) { char *window_class_down = g_ascii_strdown (class_name, -1); l = g_hash_table_lookup (priv->desktop_id_table, window_class_down); g_free (window_class_down); for (; l; l = l->next) { desktop_file = l->data; if (desktop_file) { desktop_class = bamf_matcher_get_desktop_file_class (self, desktop_file); if ((!filter_by_wmclass && !desktop_class) || g_strcmp0 (desktop_class, target_class) == 0) { if (!g_list_find_custom (desktop_files, desktop_file, (GCompareFunc) g_strcmp0)) { desktop_files = g_list_prepend (desktop_files, g_strdup (desktop_file)); } } } } desktop_files = g_list_reverse (desktop_files); } GList *pid_list = bamf_matcher_possible_applications_for_window_process (self, window); /* Append these files to the end to give preference to class_name style picking. This style of matching is prefered and used by GNOME Shell however does not work very well in practice, thus requiring the fallback here */ for (l = pid_list; l; l = l->next) { desktop_file = l->data; if (g_list_find_custom (desktop_files, desktop_file, (GCompareFunc) g_strcmp0)) { g_free (desktop_file); } else { gboolean append = FALSE; if (target_class) { desktop_class = bamf_matcher_get_desktop_file_class (self, desktop_file); if ((!filter_by_wmclass && !desktop_class) || g_strcmp0 (desktop_class, target_class) == 0) { append = TRUE; } } else { append = TRUE; } if (append) { /* If we're adding a .desktop file stored in the desktop folder, give it the priority it should have. */ GList *last = NULL; if (is_desktop_folder_item (desktop_file, -1)) { GList *ll; for (ll = desktop_files; ll; ll = ll->next) { if (!is_desktop_folder_item (ll->data, -1)) { last = ll; break; } } } desktop_files = g_list_insert_before (desktop_files, last, desktop_file); } else { g_free (desktop_file); } } } g_list_free (pid_list); } if (!desktop_files && filter_by_wmclass) { desktop_files = bamf_matcher_get_class_matching_desktop_files (self, target_class); } if (target_class_out) { *target_class_out = target_class; } return desktop_files; } static BamfApplication * bamf_matcher_get_application_for_window (BamfMatcher *self, BamfWindow *bamf_window) { GList *possible_apps, *l; BamfLegacyWindow *window; const gchar *win_class_name; const gchar *target_class = NULL; const gchar *app_class = NULL; const gchar *app_desktop = NULL; BamfApplication *app = NULL, *best = NULL; g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); g_return_val_if_fail (BAMF_IS_WINDOW (bamf_window), NULL); window = bamf_window_get_window (bamf_window); if (bamf_legacy_window_get_window_type (window) != BAMF_WINDOW_NORMAL) { BamfLegacyWindow *transient = bamf_legacy_window_get_transient (window); if (transient) { Window xid = bamf_legacy_window_get_xid (transient); app = bamf_matcher_get_application_by_xid (self, xid); if (BAMF_IS_APPLICATION (app)) return app; } } win_class_name = bamf_legacy_window_get_class_name (window); possible_apps = bamf_matcher_possible_applications_for_window (self, bamf_window, &target_class); app_class = target_class; /* Loop over every possible desktop file that could match the window, and try * to reuse an already-opened window that uses it. * Desktop files are ordered by priority, so we try to use the first possible, * wm_class matching applications have the priority, btw. */ if (possible_apps) { /* primary matching */ for (l = possible_apps; l; l = l->next) { const gchar *desktop_file = l->data; app = bamf_matcher_get_application_by_desktop_file (self, desktop_file); if (BAMF_IS_APPLICATION (app)) { const gchar *app_desktop_class; app_desktop_class = bamf_application_get_wmclass (app); if (target_class && app_desktop_class && strcasecmp (target_class, app_desktop_class) == 0) { best = app; break; } else if (!best) { best = app; } } } /* If a "best" application has been found, we should check again if the * desktop file that is going to be used is really the best one we have. * To do this, we compare the window class name with the desktop class * of both candidates to ensure that really is the best one. * This is important to avoid that very-similar (which differ only by * StartupWMClass) running desktop files, would be wrongly used to match * an incompatible window. */ if (BAMF_IS_APPLICATION (best) && possible_apps) { const gchar *best_app_desktop = bamf_application_get_desktop_file (best); const gchar *best_desktop = possible_apps->data; if (win_class_name && g_strcmp0 (best_app_desktop, best_desktop) != 0) { const gchar *best_app_class; const gchar *best_desktop_class; best_app_class = bamf_application_get_wmclass (best); best_desktop_class = bamf_matcher_get_desktop_file_class (self, best_desktop); /* We compare the two classes using their "distance" from the * desidered class value */ if (best_app_class && best_desktop_class) { int max_chars = strlen (win_class_name); int app_diff = strncasecmp (win_class_name, best_app_class, max_chars); int desktop_diff = strncasecmp (win_class_name, best_desktop_class, max_chars); if (abs (desktop_diff) < abs (app_diff)) { best = bamf_matcher_get_application_by_desktop_file (self, best_desktop); app_desktop = best_desktop; } } } } } else { /* secondary matching */ GList *a; BamfView *view; const gchar *app_desktop_class; const char *win_instance_name = bamf_legacy_window_get_class_instance_name (window); const char *exec_string = bamf_legacy_window_get_exec_string (window); char *trimmed_exec = bamf_matcher_get_trimmed_exec (self, exec_string); if (trimmed_exec || win_class_name || win_instance_name) { for (a = self->priv->views; a; a = a->next) { view = a->data; if (!BAMF_IS_APPLICATION (view)) continue; app = BAMF_APPLICATION (view); if (bamf_application_contains_similar_to_window (app, bamf_window)) { GList *ll; gboolean found_exec = FALSE; for (ll = bamf_view_get_children (BAMF_VIEW (app)); ll && !found_exec; ll = ll->next) { if (!BAMF_IS_WINDOW (ll->data)) continue; BamfLegacyWindow *w = bamf_window_get_window (BAMF_WINDOW (ll->data)); const char *wexec = bamf_legacy_window_get_exec_string (w); char *wtrimmed = bamf_matcher_get_trimmed_exec (self, wexec); if (g_strcmp0 (trimmed_exec, wtrimmed) == 0) { best = BAMF_APPLICATION (view); found_exec = TRUE; } g_free (wtrimmed); } if (!found_exec) continue; app_desktop_class = bamf_application_get_wmclass (app); if (target_class && g_strcmp0 (target_class, app_desktop_class) == 0) { best = app; break; } else if (!best) { best = app; } } } } g_free (trimmed_exec); } if (!best) { if (app_desktop) { best = bamf_application_new_from_desktop_file (app_desktop); } else if (possible_apps) { best = bamf_application_new_from_desktop_files (possible_apps); } else { best = bamf_application_new (); } bamf_application_set_wmclass (best, app_class); } g_list_free_full (possible_apps, g_free); return best; } /* Ensures that the window hint is set if a registered pid matches, and that set window hints are already known to bamfdaemon */ static void ensure_window_hint_set (BamfMatcher *self, BamfLegacyWindow *window) { GList *pids, *l; GHashTable *registered_pids; char *desktop_file_hint = NULL; gpointer key; guint pid; g_return_if_fail (BAMF_IS_MATCHER (self)); g_return_if_fail (BAMF_IS_LEGACY_WINDOW (window)); registered_pids = self->priv->registered_pids; /* Some windows such as web applications shares the pid with their parent * browser so, we have to ignore them */ if (bamf_matcher_window_skips_hint_set (self, window)) { return; } desktop_file_hint = bamf_legacy_window_get_hint (window, _BAMF_DESKTOP_FILE); if (desktop_file_hint) { /* already set, make sure we know about this * fact for future windows of this applications */ pid = bamf_legacy_window_get_pid (window); if (pid > 0) { key = GUINT_TO_POINTER (pid); if (!g_hash_table_lookup (registered_pids, key)) { g_hash_table_insert (registered_pids, key, g_strdup (desktop_file_hint)); } } g_free (desktop_file_hint); return; } pids = pid_parent_tree (self, bamf_legacy_window_get_pid (window)); for (l = pids; l; l = l->next) { key = l->data; desktop_file_hint = g_hash_table_lookup (registered_pids, key); if (desktop_file_hint != NULL && desktop_file_hint[0] != '\0') break; } g_list_free (pids); if (desktop_file_hint) bamf_legacy_window_set_hint (window, _BAMF_DESKTOP_FILE, desktop_file_hint); } static void on_raw_window_class_changed (BamfLegacyWindow *window, BamfMatcher* self) { BamfWindow *bamf_win; BamfApplication *old_app, *new_app; g_return_if_fail (BAMF_IS_MATCHER (self)); g_return_if_fail (BAMF_IS_LEGACY_WINDOW (window)); guint xid = bamf_legacy_window_get_xid (window); old_app = bamf_matcher_get_application_by_xid (self, xid); if (!old_app) return; bamf_win = bamf_application_get_window (old_app, xid); if (bamf_win) { new_app = bamf_matcher_get_application_for_window (self, bamf_win); if (new_app) { if (old_app != new_app) { g_object_ref (bamf_win); bamf_view_remove_child (BAMF_VIEW (old_app), BAMF_VIEW (bamf_win)); if (!bamf_matcher_is_view_registered (self, BAMF_VIEW (new_app))) { bamf_matcher_register_view_stealing_ref (self, BAMF_VIEW (new_app)); } bamf_view_add_child (BAMF_VIEW (new_app), BAMF_VIEW (bamf_win)); g_object_unref (bamf_win); } else { if (!bamf_matcher_is_view_registered (self, BAMF_VIEW (new_app))) { /* This is probably never happening, but just in case... */ g_object_unref (new_app); } } } } } static void on_raw_window_closed (BamfLegacyWindow *window, BamfMatcher* self) { g_signal_handlers_disconnect_by_data (window, self); } static void handle_raw_window (BamfMatcher *self, BamfLegacyWindow *window) { BamfWindow *bamf_win; BamfApplication *bamf_app; g_return_if_fail (BAMF_IS_MATCHER (self)); g_return_if_fail (BAMF_IS_LEGACY_WINDOW (window)); g_signal_connect (window, "class-changed", G_CALLBACK (on_raw_window_class_changed), self); g_signal_connect (window, "closed", G_CALLBACK (on_raw_window_closed), self); guint pid = bamf_legacy_window_get_pid (window); if (pid > 1 && !g_list_find (self->priv->known_pids, GUINT_TO_POINTER (pid))) self->priv->known_pids = g_list_prepend (self->priv->known_pids, GUINT_TO_POINTER (pid)); ensure_window_hint_set (self, window); /* We need to make our objects for bus export, the quickest way to do this, though not * always the best is to simply go window by window creating new applications as needed. */ bamf_win = bamf_window_new (window); bamf_matcher_register_view_stealing_ref (self, BAMF_VIEW (bamf_win)); bamf_app = bamf_matcher_get_application_for_window (self, bamf_win); if (!bamf_matcher_is_view_registered (self, BAMF_VIEW (bamf_app))) { bamf_matcher_register_view_stealing_ref (self, BAMF_VIEW (bamf_app)); } bamf_view_add_child (BAMF_VIEW (bamf_app), BAMF_VIEW (bamf_win)); } static char * get_unity_control_center_window_hint (BamfMatcher * self, BamfLegacyWindow * window) { const gchar *role; GList *list; g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (window), NULL); role = bamf_legacy_window_get_role (window); if (role) { gchar *exec = g_strconcat ("unity-control-center ", role, NULL); list = g_hash_table_lookup (self->priv->desktop_file_table, exec); g_free (exec); } if (!role || !list) { list = g_hash_table_lookup (self->priv->desktop_id_table, "unity-control-center"); } return (list ? (char *) list->data : NULL); } static void on_unity_control_center_window_role_changed (BamfLegacyWindow *window, BamfMatcher* self) { g_return_if_fail (BAMF_IS_MATCHER (self)); g_return_if_fail (BAMF_IS_LEGACY_WINDOW (window)); char *old_hint; const char *new_hint; old_hint = bamf_legacy_window_get_hint (window, _BAMF_DESKTOP_FILE); new_hint = get_unity_control_center_window_hint (self, window); if (new_hint && g_strcmp0 (new_hint, old_hint) != 0) { bamf_legacy_window_reopen (window); } g_free (old_hint); } static void handle_window_opening (BamfLegacyScreen *screen, const gchar *desktop_id, SnStartupSequence *startup_sequence, BamfMatcher *self) { bamf_matcher_set_starting_desktop_file (self, desktop_id, startup_sequence, TRUE); } static void handle_window_opening_finished (BamfLegacyScreen *screen, const gchar *desktop_id, BamfMatcher *self) { bamf_matcher_set_starting_desktop_file (self, desktop_id, NULL, FALSE); } static void handle_window_opened (BamfLegacyScreen * screen, BamfLegacyWindow * window, BamfMatcher *self) { g_return_if_fail (BAMF_IS_MATCHER (self)); g_return_if_fail (BAMF_IS_LEGACY_WINDOW (window)); BamfWindowType win_type = bamf_legacy_window_get_window_type (window); if (win_type == BAMF_WINDOW_DESKTOP) { BamfWindow *bamfwindow = bamf_window_new (window); bamf_matcher_register_view_stealing_ref (self, BAMF_VIEW (bamfwindow)); return; } if (is_libreoffice_window (window)) { if (win_type == BAMF_WINDOW_SPLASHSCREEN || win_type == BAMF_WINDOW_TOOLBAR) { return; } } else if (g_strcmp0 (bamf_legacy_window_get_class_name (window), "Unity-control-center") == 0) { char *old_hint = bamf_legacy_window_get_hint (window, _BAMF_DESKTOP_FILE); const char *new_hint = get_unity_control_center_window_hint (self, window); if (new_hint && g_strcmp0 (old_hint, new_hint) != 0) { bamf_legacy_window_set_hint (window, _BAMF_DESKTOP_FILE, new_hint); } g_signal_connect (window, "role-changed", (GCallback) on_unity_control_center_window_role_changed, self); g_free (old_hint); } /* we have a window who is ready to be matched */ handle_raw_window (self, window); } static void handle_stacking_changed (BamfLegacyScreen * screen, BamfMatcher *self) { g_signal_emit_by_name (self, "stacking-order-changed"); } void bamf_matcher_load_desktop_file (BamfMatcher * self, const char * desktop_file) { GList *vl, *wl; g_return_if_fail (BAMF_IS_MATCHER (self)); if (is_autostart_desktop_file (desktop_file)) return; load_desktop_file_to_table (self, desktop_file, self->priv->desktop_file_table, self->priv->desktop_id_table, self->priv->desktop_class_table); /* If an application with no .desktop file has windows that matches * the new added .desktop file, then we try to re-match them. * We use another list to save the windows that should be re-matched to avoid * that the list that we're iterating is changed, since reopening a window * makes it to be removed from the views. */ GList *to_rematch = NULL; for (vl = self->priv->views; vl; vl = vl->next) { if (!BAMF_IS_APPLICATION (vl->data)) continue; BamfApplication *app = BAMF_APPLICATION (vl->data); if (!bamf_application_get_desktop_file (app)) { GList *children = bamf_view_get_children (BAMF_VIEW (app)); for (wl = children; wl; wl = wl->next) { if (!BAMF_IS_WINDOW (wl->data)) continue; BamfWindow *win = BAMF_WINDOW (wl->data); GList *desktops = bamf_matcher_possible_applications_for_window (self, win, NULL); if (g_list_find_custom (desktops, desktop_file, (GCompareFunc) g_strcmp0)) { BamfLegacyWindow *legacy_window = bamf_window_get_window (win); to_rematch = g_list_prepend (to_rematch, legacy_window); } g_list_free_full (desktops, g_free); } } } for (wl = to_rematch; wl; wl = wl->next) { BamfLegacyWindow *legacy_window = BAMF_LEGACY_WINDOW (wl->data); bamf_legacy_window_reopen (legacy_window); } g_list_free (to_rematch); } gboolean is_autostart_desktop_file (const gchar *desktop_file) { gchar *data_dir; gchar *dirname; gboolean autostart; gint i; g_return_val_if_fail (desktop_file, FALSE); autostart = FALSE; dirname = g_path_get_dirname (desktop_file); data_dir = g_build_filename (g_get_user_config_dir (), "autostart", NULL); if (g_strcmp0 (dirname, data_dir) == 0) { autostart = TRUE; } g_free (data_dir); if (!autostart) { const gchar * const * data_dirs = g_get_system_config_dirs (); for (i = 0; data_dirs[i]; ++i) { data_dir = g_build_filename (data_dirs[i], "autostart", NULL); if (g_strcmp0 (dirname, data_dir) == 0) { autostart = TRUE; g_free (data_dir); break; } g_free (data_dir); } } g_free (dirname); return autostart; } gboolean is_valid_desktop_file (const gchar *desktop_file) { if (!desktop_file || desktop_file[0] == '\0') return FALSE; if (!g_file_test (desktop_file, G_FILE_TEST_EXISTS)) return FALSE; return TRUE; } gboolean is_visible_desktop_file (BamfMatcher *self, const gchar *desktop_file) { if (!is_valid_desktop_file (desktop_file)) return FALSE; if (is_no_display_desktop (self, desktop_file)) return FALSE; if (is_autostart_desktop_file (desktop_file)) return FALSE; return TRUE; } void bamf_matcher_register_desktop_file_for_pid (BamfMatcher * self, const gchar * desktop_file, guint64 pid) { gpointer key; BamfLegacyScreen *screen; GList *windows, *pids, *l, *ll; gboolean matching_window_found; g_return_if_fail (BAMF_IS_MATCHER (self)); g_return_if_fail (desktop_file); if (!is_visible_desktop_file (self, desktop_file)) return; key = GUINT_TO_POINTER (pid); g_hash_table_insert (self->priv->registered_pids, key, g_strdup (desktop_file)); screen = bamf_legacy_screen_get_default (); g_return_if_fail (BAMF_IS_LEGACY_SCREEN (screen)); windows = bamf_legacy_screen_get_windows (screen); matching_window_found = FALSE; for (l = windows; l; l = l->next) { BamfLegacyWindow *window = l->data; if (!BAMF_IS_LEGACY_WINDOW (window)) continue; pids = pid_parent_tree (self, bamf_legacy_window_get_pid (window)); for (ll = pids; ll; ll = ll->next) { if (pid == GPOINTER_TO_UINT (ll->data)) { matching_window_found = TRUE; break; } } g_list_free (pids); if (matching_window_found) { ensure_window_hint_set (self, window); break; } } } void bamf_matcher_set_starting_desktop_file (BamfMatcher *self, const char *desktop_file, SnStartupSequence *startup_sequence, gboolean starting) { BamfApplication *app; g_return_if_fail (BAMF_IS_MATCHER (self)); g_return_if_fail (desktop_file != NULL); if (!is_visible_desktop_file (self, desktop_file)) return; app = bamf_matcher_get_application_by_desktop_file (self, desktop_file); if (!BAMF_IS_APPLICATION (app) && starting) { app = bamf_application_new_from_desktop_file (desktop_file); if (!bamf_matcher_is_view_registered (self, BAMF_VIEW (app))) { bamf_matcher_register_view_stealing_ref (self, BAMF_VIEW (app)); } } if (BAMF_IS_APPLICATION (app)) { bamf_view_set_starting (BAMF_VIEW (app), startup_sequence, starting); } } const char * bamf_matcher_get_desktop_file_class (BamfMatcher * self, const char * desktop_file) { g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); g_return_val_if_fail (desktop_file, NULL); return g_hash_table_lookup (self->priv->desktop_class_table, desktop_file); } static int x_error_handler (Display *display, XErrorEvent *event) { /* We hardly care, this means one of our get or set property calls didn't work * while this kind of sucks, it wont effect the running of the program except to * perhaps reduce the efficiency of the application */ return 0; } const char * bamf_matcher_get_active_application (BamfMatcher *matcher) { GList *l; BamfView *view; BamfMatcherPrivate *priv; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); priv = matcher->priv; for (l = priv->views; l; l = l->next) { view = l->data; if (!BAMF_IS_APPLICATION (view)) continue; if (bamf_view_is_active (view)) { return bamf_view_get_path (view); } } return ""; } const char * bamf_matcher_get_active_window (BamfMatcher *matcher) { GList *l; BamfView *view; BamfMatcherPrivate *priv; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); priv = matcher->priv; for (l = priv->views; l; l = l->next) { view = l->data; if (!BAMF_IS_WINDOW (view)) continue; if (bamf_view_is_active (view)) { return bamf_view_get_path (view); } } return ""; } const char * bamf_matcher_application_for_xid (BamfMatcher *matcher, guint32 xid) { BamfApplication *app; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); app = bamf_matcher_get_application_by_xid (matcher, xid); if (BAMF_IS_APPLICATION (app)) return bamf_view_get_path (BAMF_VIEW (app)); return ""; } static gint compare_windows_by_stack_order (gconstpointer a, gconstpointer b) { g_return_val_if_fail (BAMF_IS_WINDOW (a), -1); g_return_val_if_fail (BAMF_IS_WINDOW (b), 1); gint idx_a = bamf_window_get_stack_position (BAMF_WINDOW (a)); gint idx_b = bamf_window_get_stack_position (BAMF_WINDOW (b)); return (idx_a < idx_b) ? -1 : 1; } GVariant * bamf_matcher_get_window_stack_for_monitor (BamfMatcher *matcher, gint monitor) { GList *l; GList *windows; BamfView *view; GVariantBuilder b; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); windows = NULL; for (l = matcher->priv->views; l; l = l->next) { if (BAMF_IS_WINDOW (l->data)) { windows = g_list_insert_sorted (windows, l->data, compare_windows_by_stack_order); } } g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); for (l = windows; l; l = l->next) { view = l->data; if (!BAMF_IS_WINDOW (view)) continue; if ((monitor >= 0 && bamf_window_get_monitor (BAMF_WINDOW (view)) == monitor) || monitor < 0) { g_variant_builder_add (&b, "s", bamf_view_get_path (view)); } } g_list_free (windows); g_variant_builder_close (&b); return g_variant_builder_end (&b); } gboolean bamf_matcher_application_is_running (BamfMatcher *matcher, const char *application) { BamfApplication *app; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), FALSE); app = bamf_matcher_get_application_by_desktop_file (matcher, application); if (BAMF_IS_APPLICATION (app)) { return bamf_view_is_running (BAMF_VIEW (app)); } return FALSE; } GVariant * bamf_matcher_window_dbus_paths (BamfMatcher *matcher) { GList *l; BamfView *view; BamfMatcherPrivate *priv; GVariantBuilder b; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); priv = matcher->priv; for (l = priv->views; l; l = l->next) { view = l->data; if (!BAMF_IS_WINDOW (view)) continue; g_variant_builder_add (&b, "s", bamf_view_get_path (view)); } g_variant_builder_close (&b); return g_variant_builder_end (&b); } GVariant * bamf_matcher_application_dbus_paths (BamfMatcher *matcher) { GList *l; BamfView *view; BamfMatcherPrivate *priv; GVariantBuilder b; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); priv = matcher->priv; for (l = priv->views; l; l = l->next) { view = l->data; if (!BAMF_IS_APPLICATION (view)) continue; g_variant_builder_add (&b, "s", bamf_view_get_path (view)); } g_variant_builder_close (&b); return g_variant_builder_end (&b); } const char * bamf_matcher_dbus_path_for_application (BamfMatcher *matcher, const char *application) { const char * path = ""; BamfApplication *app; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); app = bamf_matcher_get_application_by_desktop_file (matcher, application); if (BAMF_IS_APPLICATION (app)) { return bamf_view_get_path (BAMF_VIEW (app)); } return path; } GList * bamf_matcher_get_favorites (BamfMatcher *matcher) { g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); return matcher->priv->favorites; } void bamf_matcher_register_favorites (BamfMatcher *matcher, const char **favorites) { const char *fav; const char **favs; BamfMatcherPrivate *priv; g_return_if_fail (BAMF_IS_MATCHER (matcher)); g_return_if_fail (favorites); priv = matcher->priv; for (favs = favorites; *favs; favs++) { fav = *favs; /* ignore things already in the list */ if (g_list_find_custom (priv->favorites, fav, (GCompareFunc) g_strcmp0)) continue; bamf_matcher_load_desktop_file (matcher, fav); priv->favorites = g_list_prepend (priv->favorites, g_strdup (fav)); } g_signal_emit (matcher, matcher_signals[FAVORITES_CHANGED], 0); } GVariant * bamf_matcher_running_application_paths (BamfMatcher *matcher) { GList *l; BamfView *view; BamfMatcherPrivate *priv; GVariantBuilder b; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); priv = matcher->priv; for (l = priv->views; l; l = l->next) { view = l->data; if (!BAMF_IS_APPLICATION (view) || !bamf_view_is_running (view)) continue; g_variant_builder_add (&b, "s", bamf_view_get_path (view)); } g_variant_builder_close (&b); return g_variant_builder_end (&b); } GVariant * bamf_matcher_running_applications_desktop_files (BamfMatcher *matcher) { GList *l; BamfView *view; BamfMatcherPrivate *priv; GSequence *paths; GSequenceIter *iter; const char *desktop_file; GVariantBuilder b; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); paths = g_sequence_new (NULL); priv = matcher->priv; for (l = priv->views; l; l = l->next) { view = l->data; if (!BAMF_IS_APPLICATION (view) || !bamf_view_is_running (view)) continue; desktop_file = bamf_application_get_desktop_file (BAMF_APPLICATION (view)); if (!desktop_file) continue; if (g_sequence_lookup (paths, (gpointer) desktop_file, (GCompareDataFunc) g_strcmp0, NULL) == NULL) { g_sequence_insert_sorted (paths, (gpointer) desktop_file, (GCompareDataFunc) g_strcmp0, NULL); } } iter = g_sequence_get_begin_iter (paths); while (!g_sequence_iter_is_end (iter)) { g_variant_builder_add (&b, "s", g_sequence_get (iter)); iter = g_sequence_iter_next (iter); } g_sequence_free (paths); g_variant_builder_close (&b); return g_variant_builder_end (&b); } GVariant * bamf_matcher_tab_dbus_paths (BamfMatcher *matcher) { GList *l; BamfView *view; BamfMatcherPrivate *priv; GVariantBuilder b; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); priv = matcher->priv; for (l = priv->views; l; l = l->next) { view = l->data; if (!BAMF_IS_TAB (view)) continue; g_variant_builder_add (&b, "s", bamf_view_get_path (view)); } g_variant_builder_close (&b); return g_variant_builder_end (&b); } GVariant * bamf_matcher_xids_for_application (BamfMatcher *matcher, const char *application) { GVariantBuilder b; GVariant *xids; BamfApplication *app; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); xids = NULL; app = bamf_matcher_get_application_by_desktop_file (matcher, application); if (BAMF_IS_APPLICATION (app)) { xids = bamf_application_get_xids (app); } if (!xids) { g_variant_builder_init (&b, G_VARIANT_TYPE ("(au)")); g_variant_builder_open (&b, G_VARIANT_TYPE ("au")); g_variant_builder_close (&b); xids = g_variant_builder_end (&b); } return xids; } static gboolean on_dbus_handle_xids_for_application (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, const gchar *application, BamfMatcher *self) { GVariant *xids = bamf_matcher_xids_for_application (self, application); g_dbus_method_invocation_return_value (invocation, xids); return TRUE; } static gboolean on_dbus_handle_tab_paths (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, BamfMatcher *self) { GVariant *tab_paths = bamf_matcher_tab_dbus_paths (self); g_dbus_method_invocation_return_value (invocation, tab_paths); return TRUE; } static gboolean on_dbus_handle_application_paths (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, BamfMatcher *self) { GVariant *app_paths = bamf_matcher_application_dbus_paths (self); g_dbus_method_invocation_return_value (invocation, app_paths); return TRUE; } static gboolean on_dbus_handle_window_paths (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, BamfMatcher *self) { GVariant *win_paths = bamf_matcher_window_dbus_paths (self); g_dbus_method_invocation_return_value (invocation, win_paths); return TRUE; } static gboolean on_dbus_handle_running_applications (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, BamfMatcher *self) { GVariant *running_apps = bamf_matcher_running_application_paths (self); g_dbus_method_invocation_return_value (invocation, running_apps); return TRUE; } static gboolean on_dbus_handle_running_applications_desktop_files (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, BamfMatcher *self) { GVariant *paths = bamf_matcher_running_applications_desktop_files (self); g_dbus_method_invocation_return_value (invocation, paths); return TRUE; } static gboolean on_dbus_handle_active_application (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, BamfMatcher *self) { const gchar *active_app = bamf_matcher_get_active_application (self); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", active_app)); return TRUE; } static gboolean on_dbus_handle_active_window (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, BamfMatcher *self) { const gchar *active_win = bamf_matcher_get_active_window (self); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", active_win)); return TRUE; } static gboolean on_dbus_handle_application_is_running (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, const gchar *application, BamfMatcher *self) { gboolean is_running = bamf_matcher_application_is_running (self, application); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", is_running)); return TRUE; } static gboolean on_dbus_handle_register_favorites (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, const char **favorites, BamfMatcher *self) { g_dbus_method_invocation_return_value (invocation, NULL); bamf_matcher_register_favorites (self, favorites); return TRUE; } static gboolean on_dbus_handle_path_for_application (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, const gchar *application, BamfMatcher *self) { const gchar *app_path = bamf_matcher_dbus_path_for_application (self, application); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", app_path)); return TRUE; } static gboolean on_dbus_handle_application_for_xid (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, guint xid, BamfMatcher *self) { const gchar *app_path = bamf_matcher_application_for_xid (self, xid); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", app_path)); return TRUE; } static gboolean on_dbus_handle_window_stack_for_monitor (BamfDBusMatcher *interface, GDBusMethodInvocation *invocation, gint monitor, BamfMatcher *self) { GVariant *windows = bamf_matcher_get_window_stack_for_monitor (self, monitor); g_dbus_method_invocation_return_value (invocation, windows); return TRUE; } static void bamf_matcher_init (BamfMatcher * self) { BamfMatcherPrivate *priv; BamfLegacyScreen *screen; int i; priv = self->priv = bamf_matcher_get_instance_private (self); priv->bad_prefixes = g_array_sized_new (FALSE, TRUE, sizeof (GRegex *), G_N_ELEMENTS (EXEC_BAD_PREFIXES)); priv->good_prefixes = g_array_sized_new (FALSE, TRUE, sizeof (GRegex *), G_N_ELEMENTS (EXEC_GOOD_PREFIXES)); priv->registered_pids = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free); for (i = 0; i < G_N_ELEMENTS (EXEC_BAD_PREFIXES); ++i) { GRegex *regex = g_regex_new (EXEC_BAD_PREFIXES[i], G_REGEX_OPTIMIZE, 0, NULL); g_array_append_val (priv->bad_prefixes, regex); } for (i = 0; i < G_N_ELEMENTS (EXEC_GOOD_PREFIXES); ++i) { GRegex *regex = g_regex_new (EXEC_GOOD_PREFIXES[i], G_REGEX_OPTIMIZE, 0, NULL); g_array_append_val (priv->good_prefixes, regex); } create_desktop_file_table (self, &(priv->desktop_file_table), &(priv->desktop_id_table), &(priv->desktop_class_table)); screen = bamf_legacy_screen_get_default (); g_signal_connect (G_OBJECT (screen), BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENING, G_CALLBACK (handle_window_opening), self); g_signal_connect (G_OBJECT (screen), BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENING_COMPLETED, G_CALLBACK (handle_window_opening_finished), self); g_signal_connect (G_OBJECT (screen), BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENING_CANCELED, G_CALLBACK (handle_window_opening_finished), self); g_signal_connect (G_OBJECT (screen), BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENED, G_CALLBACK (handle_window_opened), self); g_signal_connect (G_OBJECT (screen), BAMF_LEGACY_SCREEN_SIGNAL_STACKING_CHANGED, G_CALLBACK (handle_stacking_changed), self); XSetErrorHandler (x_error_handler); /* Registering signal callbacks to reply to dbus method calls */ g_signal_connect (self, "handle-xids-for-application", G_CALLBACK (on_dbus_handle_xids_for_application), self); g_signal_connect (self, "handle-tab-paths", G_CALLBACK (on_dbus_handle_tab_paths), self); g_signal_connect (self, "handle-application-paths", G_CALLBACK (on_dbus_handle_application_paths), self); g_signal_connect (self, "handle-window-paths", G_CALLBACK (on_dbus_handle_window_paths), self); g_signal_connect (self, "handle-running-applications", G_CALLBACK (on_dbus_handle_running_applications), self); g_signal_connect (self, "handle-running-applications-desktop-files", G_CALLBACK (on_dbus_handle_running_applications_desktop_files), self); g_signal_connect (self, "handle-active-window", G_CALLBACK (on_dbus_handle_active_window), self); g_signal_connect (self, "handle-active-application", G_CALLBACK (on_dbus_handle_active_application), self); g_signal_connect (self, "handle-application-is-running", G_CALLBACK (on_dbus_handle_application_is_running), self); g_signal_connect (self, "handle-register-favorites", G_CALLBACK (on_dbus_handle_register_favorites), self); g_signal_connect (self, "handle-path-for-application", G_CALLBACK (on_dbus_handle_path_for_application), self); g_signal_connect (self, "handle-application-for-xid", G_CALLBACK (on_dbus_handle_application_for_xid), self); g_signal_connect (self, "handle-window-stack-for-monitor", G_CALLBACK (on_dbus_handle_window_stack_for_monitor), self); } static void bamf_matcher_dispose (GObject *object) { BamfMatcher *self = (BamfMatcher *) object; BamfMatcherPrivate *priv = self->priv; while (priv->views) { bamf_matcher_unregister_view (self, priv->views->data); } G_OBJECT_CLASS (bamf_matcher_parent_class)->dispose (object); } static void bamf_matcher_finalize (GObject *object) { BamfMatcher *self = (BamfMatcher *) object; BamfMatcherPrivate *priv = self->priv; BamfLegacyScreen *screen = bamf_legacy_screen_get_default (); GList *l; int i; for (i = 0; i < priv->bad_prefixes->len; i++) { GRegex *regex = g_array_index (priv->bad_prefixes, GRegex *, i); g_regex_unref (regex); } for (i = 0; i < priv->good_prefixes->len; i++) { GRegex *regex = g_array_index (priv->good_prefixes, GRegex *, i); g_regex_unref (regex); } g_array_free (priv->bad_prefixes, TRUE); g_array_free (priv->good_prefixes, TRUE); g_hash_table_destroy (priv->desktop_id_table); g_hash_table_destroy (priv->desktop_file_table); g_hash_table_destroy (priv->desktop_class_table); g_hash_table_destroy (priv->registered_pids); g_list_free (priv->no_display_desktop); if (priv->opened_closed_paths_table) { g_hash_table_destroy (priv->opened_closed_paths_table); } if (priv->dispatch_changes_id != 0) { g_source_remove (priv->dispatch_changes_id); priv->dispatch_changes_id = 0; } g_list_free (priv->known_pids); g_list_free_full (priv->views, g_object_unref); g_signal_handlers_disconnect_by_data (screen, self); for (l = priv->monitors; l; l = l->next) g_signal_handlers_disconnect_by_data (G_OBJECT (l->data), self); g_list_free_full (priv->monitors, g_object_unref); g_list_free_full (priv->favorites, g_free); priv->active_app = NULL; priv->active_win = NULL; static_matcher = NULL; G_OBJECT_CLASS (bamf_matcher_parent_class)->finalize (object); } static void bamf_matcher_class_init (BamfMatcherClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = bamf_matcher_dispose; object_class->finalize = bamf_matcher_finalize; matcher_signals [FAVORITES_CHANGED] = g_signal_new ("favorites-changed", G_OBJECT_CLASS_TYPE (klass), 0, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); } BamfMatcher * bamf_matcher_get_default (void) { if (!BAMF_IS_MATCHER (static_matcher)) { static_matcher = g_object_new (BAMF_TYPE_MATCHER, NULL); } return static_matcher; } ./src/bamf-matcher.h0000644000004100000410000001245614203512426014540 0ustar www-datawww-data/* * Copyright (C) 2010 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef __BAMFMATCHER_H__ #define __BAMFMATCHER_H__ #include "bamf-view.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define BAMF_TYPE_MATCHER (bamf_matcher_get_type ()) #define BAMF_MATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_MATCHER, BamfMatcher)) #define BAMF_IS_MATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_MATCHER)) #define BAMF_MATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_MATCHER, BamfMatcherClass)) #define BAMF_IS_MATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_MATCHER)) #define BAMF_MATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_MATCHER, BamfMatcherClass)) #define _BAMF_DESKTOP_FILE "_BAMF_DESKTOP_FILE" typedef struct _BamfMatcher BamfMatcher; typedef struct _BamfMatcherClass BamfMatcherClass; typedef struct _BamfMatcherPrivate BamfMatcherPrivate; struct _BamfMatcherClass { BamfDBusMatcherSkeletonClass parent; }; struct _BamfMatcher { BamfDBusMatcherSkeleton parent; /* private */ BamfMatcherPrivate *priv; }; GType bamf_matcher_get_type (void) G_GNUC_CONST; void bamf_matcher_load_desktop_file (BamfMatcher * self, const char * desktop_file); void bamf_matcher_register_desktop_file_for_pid (BamfMatcher * self, const char *application, guint64 pid); void bamf_matcher_set_starting_desktop_file (BamfMatcher * self, const char *desktop_file, SnStartupSequence *sequence, gboolean starting); const char * bamf_matcher_get_desktop_file_class (BamfMatcher * self, const char * desktop_file); const char * bamf_matcher_get_active_application (BamfMatcher *matcher); const char * bamf_matcher_get_active_window (BamfMatcher *matcher); const char * bamf_matcher_application_for_xid (BamfMatcher *matcher, guint32 xid); gboolean bamf_matcher_application_is_running (BamfMatcher *matcher, const char *application); GVariant * bamf_matcher_application_dbus_paths (BamfMatcher *matcher); GVariant * bamf_matcher_window_dbus_paths (BamfMatcher *matcher); const char * bamf_matcher_dbus_path_for_application (BamfMatcher *matcher, const char *application); void bamf_matcher_register_favorites (BamfMatcher *matcher, const char **favorites); GList * bamf_matcher_get_favorites (BamfMatcher *matcher); GVariant * bamf_matcher_running_application_paths (BamfMatcher *matcher); GVariant * bamf_matcher_tab_dbus_paths (BamfMatcher *matcher); GVariant * bamf_matcher_xids_for_application (BamfMatcher *matcher, const char *application); GVariant * bamf_matcher_get_window_stack_for_monitor (BamfMatcher *matcher, gint monitor); gboolean bamf_matcher_is_valid_process_prefix (BamfMatcher *matcher, const char *process_name); gboolean bamf_matcher_is_valid_class_name (BamfMatcher *matcher, const char *class_name); char * bamf_matcher_get_trimmed_exec (BamfMatcher *matcher, const char *exec_string); BamfView * bamf_matcher_get_view_by_path (BamfMatcher *matcher, const char *view_path); BamfMatcher * bamf_matcher_get_default (void); #endif ./src/bamf-legacy-window-test.c0000644000004100000410000003710314203512426016632 0ustar www-datawww-data/* * Copyright (C) 2010 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * */ #include "bamf-legacy-window-test.h" #include "bamf-legacy-screen-private.h" G_DEFINE_TYPE (BamfLegacyWindowTest, bamf_legacy_window_test, BAMF_TYPE_LEGACY_WINDOW); guint bamf_legacy_window_test_get_pid (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->pid; } guint32 bamf_legacy_window_test_get_xid (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->xid; } void bamf_legacy_window_test_set_attention (BamfLegacyWindowTest *self, gboolean val) { if (self->needs_attention == val) return; self->needs_attention = val; g_signal_emit_by_name (self, "state-changed"); } gboolean bamf_legacy_window_test_needs_attention (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->needs_attention; } void bamf_legacy_window_test_set_active (BamfLegacyWindowTest *self, gboolean val) { if (self->is_active == val) return; self->is_active = val; g_signal_emit_by_name (self, "state-changed"); } gboolean bamf_legacy_window_test_is_active (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->is_active; } void bamf_legacy_window_test_set_desktop (BamfLegacyWindowTest *self, gboolean val) { if (self->is_desktop == val) return; self->is_desktop = val; g_signal_emit_by_name (self, "state-changed"); } gboolean bamf_legacy_window_test_is_desktop (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->is_desktop; } void bamf_legacy_window_test_set_skip (BamfLegacyWindowTest *self, gboolean val) { if (self->is_skip == val) return; self->is_skip = val; g_signal_emit_by_name (self, "state-changed"); } gboolean bamf_legacy_window_test_is_skip_tasklist (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->is_skip; } void bamf_legacy_window_test_set_name (BamfLegacyWindowTest *self, const char *val) { if (g_strcmp0 (self->name, val) == 0) return; g_free (self->name); self->name = g_strdup (val); g_signal_emit_by_name (self, "name-changed"); } void bamf_legacy_window_test_set_icon (BamfLegacyWindowTest *self, const char *val) { if (g_strcmp0 (self->icon, val) == 0) return; g_free (self->icon); self->icon = g_strdup (val); } void bamf_legacy_window_test_set_role (BamfLegacyWindowTest *self, const char *val) { if (g_strcmp0 (self->role, val) == 0) return; g_free (self->role); self->role = g_strdup (val); g_signal_emit_by_name (self, "role-changed"); } void bamf_legacy_window_test_set_wmclass (BamfLegacyWindowTest *self, const char *class_name, const char *instance_name) { gboolean changed = FALSE; if (g_strcmp0 (self->wm_class_name, class_name) != 0) { g_free (self->wm_class_name); self->wm_class_name = g_strdup (class_name); changed = TRUE; } if (g_strcmp0 (self->wm_class_instance, instance_name) != 0) { g_free (self->wm_class_instance); self->wm_class_instance = g_strdup (instance_name); changed = TRUE; } if (changed) g_signal_emit_by_name (self, "class-changed"); } static const char * bamf_legacy_window_test_get_name (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->name; } static const char * bamf_legacy_window_test_get_role (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->role; } static BamfLegacyWindow * bamf_legacy_window_test_get_transient (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->transient_window; } static const char * bamf_legacy_window_test_get_class_name (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->wm_class_name; } static const char * bamf_legacy_window_test_get_class_instance_name (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->wm_class_instance; } const char * bamf_legacy_window_test_get_exec_string (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->exec; } const char * bamf_legacy_window_test_get_working_dir (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->working_dir; } char * bamf_legacy_window_test_get_process_name (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return g_strdup (self->process_name); } char * bamf_legacy_window_test_get_app_id (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (legacy_window), NULL); self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return g_strdup (self->application_id); } char * bamf_legacy_window_test_get_unique_bus_name (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (legacy_window), NULL); self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return g_strdup (self->unique_bus_name); } char * bamf_legacy_window_test_get_menu_object_path (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (legacy_window), NULL); self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return g_strdup (self->dbus_menu_object_path); } void bamf_legacy_window_test_get_geometry (BamfLegacyWindow *legacy_window, gint *x, gint *y, gint *width, gint *height) { BamfLegacyWindowTest *self; g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (legacy_window)); self = BAMF_LEGACY_WINDOW_TEST (legacy_window); *x = self->geometry.x; *y = self->geometry.y; *width = self->geometry.width; *height = self->geometry.height; } BamfWindowMaximizationType bamf_legacy_window_test_maximized (BamfLegacyWindow *legacy_window) { BamfLegacyWindowTest *self; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (legacy_window), BAMF_WINDOW_FLOATING); self = BAMF_LEGACY_WINDOW_TEST (legacy_window); return self->maximized; } void bamf_legacy_window_test_close (BamfLegacyWindowTest *self) { self->is_closed = TRUE; g_signal_emit_by_name (self, "closed"); } void bamf_legacy_window_test_set_geometry (BamfLegacyWindowTest *self, int x, int y, int width, int height) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (self)); self->geometry.x = x; self->geometry.y = y; self->geometry.width = width; self->geometry.height = height; g_signal_emit_by_name (self, BAMF_LEGACY_WINDOW_SIGNAL_GEOMETRY_CHANGED); } void bamf_legacy_window_test_set_maximized (BamfLegacyWindowTest *self, BamfWindowMaximizationType maximized) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (self)); self->maximized = maximized; g_signal_emit_by_name (self, BAMF_LEGACY_WINDOW_SIGNAL_GEOMETRY_CHANGED); g_signal_emit_by_name (self, BAMF_LEGACY_WINDOW_SIGNAL_STATE_CHANGED); } void bamf_legacy_window_test_set_application_id (BamfLegacyWindowTest *self, const char *id) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (self)); self->application_id = g_strdup (id); } void bamf_legacy_window_test_set_unique_bus_name (BamfLegacyWindowTest *self, const char *bus_name) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (self)); self->unique_bus_name = g_strdup (bus_name); } void bamf_legacy_window_test_set_dbus_menu_object_path (BamfLegacyWindowTest *self, const char *object_path) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (self)); self->dbus_menu_object_path = g_strdup (object_path); } gboolean bamf_legacy_window_test_is_closed (BamfLegacyWindow *window) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (window), TRUE); BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (window); return self->is_closed; } static void handle_destroy_notify (BamfLegacyWindowTest *copy, BamfLegacyWindowTest *self_was_here) { BamfLegacyScreen *screen = bamf_legacy_screen_get_default (); _bamf_legacy_screen_open_test_window (screen, copy); } void bamf_legacy_window_test_reopen (BamfLegacyWindow *window) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (window)); BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (window); BamfLegacyWindowTest *copy = bamf_legacy_window_copy (self); g_object_weak_ref (G_OBJECT (self), (GWeakNotify) handle_destroy_notify, copy); bamf_legacy_window_test_close (self); } BamfWindowType bamf_legacy_window_test_get_window_type (BamfLegacyWindow *window) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (window), TRUE); BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (window); return self->window_type; } char * bamf_legacy_window_test_get_hint (BamfLegacyWindow *window, const char *name) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (window), NULL); BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (window); return g_strdup (g_hash_table_lookup (self->hints, name)); } void bamf_legacy_window_test_set_hint (BamfLegacyWindow *window, const char *name, const char *value) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (window)); BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (window); g_hash_table_insert (self->hints, g_strdup (name), g_strdup (value)); } static char * bamf_legacy_window_test_save_mini_icon (BamfLegacyWindow *window) { return g_strdup (BAMF_LEGACY_WINDOW_TEST (window)->icon); } GtkWidget * bamf_legacy_window_test_get_action_menu (BamfLegacyWindow *window) { return NULL; } void bamf_legacy_window_test_show_action_menu (BamfLegacyWindow *window, guint32 time, guint button, gint x, gint y) {} static void bamf_legacy_window_test_finalize (GObject *object) { BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (object); g_free (self->name); g_free (self->icon); g_free (self->role); g_free (self->wm_class_name); g_free (self->wm_class_instance); g_free (self->exec); g_free (self->working_dir); g_free (self->process_name); g_free (self->application_id); g_free (self->unique_bus_name); g_free (self->dbus_menu_object_path); g_hash_table_unref (self->hints); G_OBJECT_CLASS (bamf_legacy_window_test_parent_class)->finalize (object); } void bamf_legacy_window_test_class_init (BamfLegacyWindowTestClass *klass) { BamfLegacyWindowClass *win_class = BAMF_LEGACY_WINDOW_CLASS (klass); GObjectClass *obj_class = G_OBJECT_CLASS (klass); obj_class->finalize = bamf_legacy_window_test_finalize; win_class->get_transient = bamf_legacy_window_test_get_transient; win_class->get_name = bamf_legacy_window_test_get_name; win_class->save_mini_icon = bamf_legacy_window_test_save_mini_icon; win_class->get_role = bamf_legacy_window_test_get_role; win_class->get_class_name = bamf_legacy_window_test_get_class_name; win_class->get_class_instance_name = bamf_legacy_window_test_get_class_instance_name; win_class->get_exec_string = bamf_legacy_window_test_get_exec_string; win_class->get_working_dir = bamf_legacy_window_test_get_working_dir; win_class->get_process_name = bamf_legacy_window_test_get_process_name; win_class->get_xid = bamf_legacy_window_test_get_xid; win_class->get_pid = bamf_legacy_window_test_get_pid; win_class->needs_attention = bamf_legacy_window_test_needs_attention; win_class->is_skip_tasklist = bamf_legacy_window_test_is_skip_tasklist; win_class->is_desktop = bamf_legacy_window_test_is_desktop; win_class->is_active = bamf_legacy_window_test_is_active; win_class->get_app_id = bamf_legacy_window_test_get_app_id; win_class->get_unique_bus_name = bamf_legacy_window_test_get_unique_bus_name; win_class->get_menu_object_path = bamf_legacy_window_test_get_menu_object_path; win_class->get_geometry = bamf_legacy_window_test_get_geometry; win_class->get_window_type = bamf_legacy_window_test_get_window_type; win_class->maximized = bamf_legacy_window_test_maximized; win_class->is_closed = bamf_legacy_window_test_is_closed; win_class->get_hint = bamf_legacy_window_test_get_hint; win_class->set_hint = bamf_legacy_window_test_set_hint; win_class->get_action_menu = bamf_legacy_window_test_get_action_menu; win_class->show_action_menu = bamf_legacy_window_test_show_action_menu; win_class->reopen = bamf_legacy_window_test_reopen; } void bamf_legacy_window_test_init (BamfLegacyWindowTest *self) { self->pid = g_random_int_range (1, 100000); self->maximized = BAMF_WINDOW_FLOATING; self->is_closed = FALSE; self->hints = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); } BamfLegacyWindowTest * bamf_legacy_window_copy (BamfLegacyWindowTest *self) { BamfLegacyWindowTest *copy; copy = g_object_new (BAMF_TYPE_LEGACY_WINDOW_TEST, NULL); copy->xid = self->xid; copy->pid = self->pid; copy->name = g_strdup (self->name); copy->icon = g_strdup (self->icon); copy->role = g_strdup (self->role); copy->wm_class_name = g_strdup (self->wm_class_name); copy->wm_class_instance = g_strdup (self->wm_class_instance); copy->exec = g_strdup (self->exec); copy->working_dir = g_strdup (self->working_dir); copy->process_name = g_strdup (self->process_name); copy->application_id = g_strdup (self->application_id); copy->unique_bus_name = g_strdup (self->unique_bus_name); copy->dbus_menu_object_path = g_strdup (self->dbus_menu_object_path); copy->transient_window = self->transient_window; copy->needs_attention = self->needs_attention; copy->is_desktop = self->is_desktop; copy->is_skip = self->is_skip; copy->is_active = self->is_active; copy->is_closed = self->is_closed; copy->geometry = self->geometry; copy->maximized = self->maximized; copy->window_type = self->window_type; copy->hints = g_hash_table_ref (self->hints); return copy; } BamfLegacyWindowTest * bamf_legacy_window_test_new (guint32 xid, const gchar *name, const gchar *wmclass_name, const gchar *exec) { BamfLegacyWindowTest *self; self = g_object_new (BAMF_TYPE_LEGACY_WINDOW_TEST, NULL); self->window_type = BAMF_WINDOW_NORMAL; self->xid = xid; self->name = g_strdup (name); self->wm_class_name = g_strdup (wmclass_name); self->exec = g_strdup (exec); self->working_dir = g_get_current_dir (); if (self->exec) { gchar **splitted_exec = g_strsplit (exec, " ", 2); gchar *tmp = g_utf8_strrchr (splitted_exec[0], -1, G_DIR_SEPARATOR); self->process_name = g_strdup (tmp ? tmp + 1 : splitted_exec[0]); g_strfreev (splitted_exec); } return self; } ./src/simple-state.txt0000644000004100000410000000035214203512426015201 0ustar www-datawww-dataopen 234 My Firstish Window gedit gedit %U open 436 My Second Window gedit gedit %U open 325 Some Firefox Window firefox firefox %U close 436 skip 325 true attention 234 true open 333 A New Window chromium-browser chromium-browser %U ./src/bamf-application.h0000644000004100000410000001224414203512426015413 0ustar www-datawww-data/* * Copyright (C) 2010-2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef __BAMFAPPLICATION_H__ #define __BAMFAPPLICATION_H__ #include "bamf-view.h" #include "bamf-window.h" #include #include #define BAMF_TYPE_APPLICATION (bamf_application_get_type ()) #define BAMF_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_APPLICATION, BamfApplication)) #define BAMF_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_APPLICATION)) #define BAMF_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_APPLICATION, BamfApplicationClass)) #define BAMF_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_APPLICATION)) #define BAMF_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_APPLICATION, BamfApplicationClass)) typedef struct _BamfApplication BamfApplication; typedef struct _BamfApplicationClass BamfApplicationClass; typedef struct _BamfApplicationPrivate BamfApplicationPrivate; struct _BamfApplicationClass { BamfViewClass parent; void (*get_application_menu) (BamfApplication *application, gchar **name, gchar **path); BamfView* (*get_focusable_child) (BamfApplication *application); char ** (*get_supported_mime_types) (BamfApplication *application); gboolean (*get_close_when_empty) (BamfApplication *application); void (*supported_mimes_changed) (BamfApplication *application, const gchar **mimes); }; struct _BamfApplication { BamfView parent; /* private */ BamfApplicationPrivate *priv; }; typedef enum { BAMF_APPLICATION_SYSTEM, /* BamfWindow container */ BAMF_APPLICATION_WEB, /* BamfTab container */ BAMF_APPLICATION_UNKNOWN, } BamfApplicationType; GType bamf_application_get_type (void) G_GNUC_CONST; void bamf_application_emit_supported_mime_types_changed (BamfApplication *application); const char * bamf_application_get_desktop_file (BamfApplication *application); void bamf_application_set_desktop_file (BamfApplication *application, const char * desktop_file); char ** bamf_application_get_supported_mime_types (BamfApplication *application); GVariant * bamf_application_get_xids (BamfApplication *application); gboolean bamf_application_manages_xid (BamfApplication *application, guint32 xid); BamfWindow * bamf_application_get_window (BamfApplication *application, guint32 xid); gboolean bamf_application_contains_similar_to_window (BamfApplication *app, BamfWindow *window); gboolean bamf_application_create_local_desktop_file (BamfApplication *app); const char * bamf_application_get_wmclass (BamfApplication *application); void bamf_application_set_wmclass (BamfApplication *application, const char *wmclass); BamfApplication * bamf_application_new (void); BamfApplication * bamf_application_new_from_desktop_file (const char * desktop_file); gboolean bamf_application_get_show_stubs (BamfApplication *application); BamfApplication * bamf_application_new_from_desktop_files (GList * desktop_files); BamfApplication * bamf_application_new_with_wmclass (const char *wmclass); void bamf_application_set_application_type (BamfApplication *application, BamfApplicationType type); BamfApplicationType bamf_application_get_application_type (BamfApplication *application); void bamf_application_get_application_menu (BamfApplication *application, gchar **name, gchar **object_path); BamfView * bamf_application_get_focusable_child (BamfApplication *application); BamfView * bamf_application_get_main_child (BamfApplication *application); gboolean bamf_application_get_close_when_empty (BamfApplication *application); gboolean bamf_application_set_desktop_file_from_id (BamfApplication *application, const char *id); #endif ./src/bamf-tab.h0000644000004100000410000000441514203512426013657 0ustar www-datawww-data/* * Copyright (C) 2010-2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Robert Carr */ #ifndef __BAMFTAB_H__ #define __BAMFTAB_H__ #include "bamf-view.h" #include #include #define BAMF_TYPE_TAB (bamf_tab_get_type ()) #define BAMF_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_TAB, BamfTab)) #define BAMF_IS_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_TAB)) #define BAMF_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_TAB, BamfTabClass)) #define BAMF_IS_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_TAB)) #define BAMF_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_TAB, BamfTabClass)) typedef struct _BamfTab BamfTab; typedef struct _BamfTabClass BamfTabClass; typedef struct _BamfTabPrivate BamfTabPrivate; typedef void (*BamfTabPreviewReadyCallback) (BamfTab *, const gchar *, gpointer); struct _BamfTabClass { BamfViewClass parent; void (*raise) (BamfTab *self); void (*close) (BamfTab *self); void (*request_preview) (BamfTab *self, BamfTabPreviewReadyCallback callback, gpointer user_data); }; struct _BamfTab { BamfView parent; /* private */ BamfTabPrivate *priv; }; GType bamf_tab_get_type (void) G_GNUC_CONST; const gchar *bamf_tab_get_desktop_id (BamfTab *self); const gchar *bamf_tab_get_location (BamfTab *self); guint64 bamf_tab_get_xid (BamfTab *self); gboolean bamf_tab_get_is_foreground_tab (BamfTab *self); void bamf_tab_raise (BamfTab *self); void bamf_tab_close (BamfTab *self); void bamf_tab_request_preview (BamfTab *self, BamfTabPreviewReadyCallback callback, gpointer user_data); #endif ./src/bamf-view.h0000644000004100000410000001125314203512426014061 0ustar www-datawww-data/* * Copyright (C) 2010-2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef __BAMFVIEW_H__ #define __BAMFVIEW_H__ #include #include #include #define SN_API_NOT_YET_FROZEN #include #undef SN_API_NOT_YET_FROZEN #define BAMF_TYPE_VIEW (bamf_view_get_type ()) #define BAMF_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_VIEW, BamfView)) #define BAMF_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_VIEW)) #define BAMF_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_VIEW, BamfViewClass)) #define BAMF_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_VIEW)) #define BAMF_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_VIEW, BamfViewClass)) typedef struct _BamfView BamfView; typedef struct _BamfViewClass BamfViewClass; typedef struct _BamfViewPrivate BamfViewPrivate; struct _BamfViewClass { BamfDBusItemObjectSkeletonClass parent; GList *names; /*< methods >*/ const char * (*view_type) (BamfView *view); char * (*stable_bus_name) (BamfView *view); /*< random stuff >*/ gboolean (* urgent_changed) (BamfView *view, gboolean urgent); gboolean (* starting_changed) (BamfView *view, gboolean starting); gboolean (* running_changed) (BamfView *view, gboolean running); gboolean (* active_changed) (BamfView *view, gboolean active); gboolean (* user_visible_changed) (BamfView *view, gboolean visible); gboolean (* closed) (BamfView *view); void (* child_added) (BamfView *view, BamfView *child); void (* child_removed) (BamfView *view, BamfView *child); /*< signals >*/ void (* closed_internal) (BamfView *view); void (* exported) (BamfView *view); }; struct _BamfView { BamfDBusItemObjectSkeleton parent; /* private */ BamfViewPrivate *priv; }; GType bamf_view_get_type (void) G_GNUC_CONST; void bamf_view_close (BamfView *view); GVariant * bamf_view_get_children_paths (BamfView *view); GList * bamf_view_get_children (BamfView *view); GVariant * bamf_view_get_parent_paths (BamfView *view); GList * bamf_view_get_parents (BamfView *view); const char * bamf_view_get_path (BamfView *view); void bamf_view_add_child (BamfView *view, BamfView *child); void bamf_view_remove_child (BamfView *view, BamfView *child); gboolean bamf_view_is_active (BamfView *view); void bamf_view_set_active (BamfView *view, gboolean active); gboolean bamf_view_is_starting (BamfView *view); void bamf_view_set_starting (BamfView *view, SnStartupSequence *startup_sequence, gboolean starting); gboolean bamf_view_is_running (BamfView *view); void bamf_view_set_running (BamfView *view, gboolean running); gboolean bamf_view_is_user_visible (BamfView *view); void bamf_view_set_user_visible (BamfView *view, gboolean user_visible); gboolean bamf_view_is_urgent (BamfView *view); void bamf_view_set_urgent (BamfView *view, gboolean urgent); void bamf_view_set_icon (BamfView *view, const char *icon); const char * bamf_view_get_icon (BamfView *view); const char * bamf_view_get_name (BamfView *view); void bamf_view_set_name (BamfView *view, const char *name); const char * bamf_view_get_parent_path (BamfView *view); BamfView * bamf_view_get_parent (BamfView *view); void bamf_view_set_parent (BamfView *view, BamfView *parent); const char * bamf_view_get_view_type (BamfView *view); gboolean bamf_view_is_on_bus (BamfView *view); const char * bamf_view_export_on_bus (BamfView *view, GDBusConnection *connection); #endif ./src/bamf-legacy-screen-private.h0000644000004100000410000000205114203512426017274 0ustar www-datawww-data/* * Copyright (C) 2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Marco Trevisan (Treviño) * */ #ifndef __BAMF_LEGACY_SCREEN_PRIVATE_H__ #define __BAMF_LEGACY_SCREEN_PRIVATE_H__ #include "bamf-legacy-screen.h" #include "bamf-legacy-window-test.h" void _bamf_legacy_screen_open_test_window (BamfLegacyScreen *self, BamfLegacyWindowTest *window); void _bamf_legacy_screen_close_test_window (BamfLegacyScreen *self, BamfLegacyWindowTest *window); #endif ./src/bamf-xutils.c0000644000004100000410000001353514203512426014437 0ustar www-datawww-data/* * Copyright (C) 2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include "bamf-xutils.h" #include #include static Display * get_xdisplay (gboolean *opened) { Display *xdisplay; xdisplay = gdk_x11_get_default_xdisplay (); if (opened) *opened = FALSE; if (!xdisplay) { xdisplay = XOpenDisplay (NULL); if (xdisplay) { if (opened) *opened = TRUE; } } return xdisplay; } static gboolean gdk_error_trap_pop_and_print (Display *dpy) { gdk_flush (); gint error_code = gdk_error_trap_pop (); if (error_code) { gchar tmp[1024]; XGetErrorText (dpy, error_code, tmp, sizeof (tmp) - 1); tmp[sizeof (tmp) - 1] = '\0'; g_warning ("Got an X error: %s\n", tmp); return TRUE; } return FALSE; } static void bamf_xutils_get_string_window_hint_and_type (Window xid, const char *atom_name, gchar** return_hint, Atom* return_type) { Display *XDisplay; gint format; gulong numItems; gulong bytesAfter; Atom type; unsigned char *buffer; gboolean close_display; if (return_hint) *return_hint = NULL; if (return_type) *return_type = AnyPropertyType; g_return_if_fail (xid != 0); g_return_if_fail (return_hint || return_type); close_display = FALSE; XDisplay = get_xdisplay (&close_display); if (!XDisplay) { g_warning ("%s: Unable to get a valid XDisplay", G_STRFUNC); return; } gdk_error_trap_push (); int result = XGetWindowProperty (XDisplay, xid, gdk_x11_get_xatom_by_name (atom_name), 0, G_MAXINT, False, AnyPropertyType, &type, &format, &numItems, &bytesAfter, &buffer); gboolean x_error = gdk_error_trap_pop_and_print (XDisplay); if (close_display) XCloseDisplay (XDisplay); if (x_error) { XFree (buffer); return; } if (result == Success && numItems > 0) { if (return_type) *return_type = type; if (return_hint && buffer && buffer[0] != '\0') { if (type == XA_STRING || type == gdk_x11_get_xatom_by_name ("UTF8_STRING")) *return_hint = g_strdup ((char*) buffer); } XFree (buffer); } } char * bamf_xutils_get_string_window_hint (Window xid, const char *atom_name) { gchar *hint = NULL; bamf_xutils_get_string_window_hint_and_type (xid, atom_name, &hint, NULL); return hint; } void bamf_xutils_set_string_window_hint (Window xid, const char *atom_name, const char *value) { Display *XDisplay; Atom type; gboolean close_display = FALSE; g_return_if_fail (xid != 0); g_return_if_fail (atom_name); g_return_if_fail (value); XDisplay = get_xdisplay (&close_display); if (!XDisplay) { g_warning ("%s: Unable to get a valid XDisplay", G_STRFUNC); return; } bamf_xutils_get_string_window_hint_and_type (xid, atom_name, NULL, &type); if (type == AnyPropertyType) { type = XA_STRING; } else if (type != XA_STRING && type != gdk_x11_get_xatom_by_name ("UTF8_STRING")) { g_error ("Impossible to set the atom %s on Window %lu", atom_name, xid); if (close_display) XCloseDisplay (XDisplay); return; } gdk_error_trap_push (); XChangeProperty (XDisplay, xid, gdk_x11_get_xatom_by_name (atom_name), type, 8, PropModeReplace, (unsigned char *) value, strlen (value)); gdk_error_trap_pop_and_print (XDisplay); if (close_display) XCloseDisplay (XDisplay); } void bamf_xutils_unset_window_hint (Window xid, const char *atom_name) { Display *XDisplay; gboolean close_display = FALSE; g_return_if_fail (xid != 0); g_return_if_fail (atom_name); XDisplay = get_xdisplay (&close_display); if (!XDisplay) { g_warning ("%s: Unable to get a valid XDisplay", G_STRFUNC); return; } gdk_error_trap_push (); XDeleteProperty (XDisplay, xid, gdk_x11_get_xatom_by_name (atom_name)); gdk_error_trap_pop_and_print (XDisplay); if (close_display) XCloseDisplay (XDisplay); } void bamf_xutils_get_window_class_hints (Window xid, char **class_instance_name, char **class_name) { Display *xdisplay; gboolean close_display = FALSE; xdisplay = get_xdisplay (&close_display); if (!xdisplay) { g_warning ("%s: Unable to get a valid XDisplay", G_STRFUNC); return; } XClassHint class_hint; class_hint.res_name = NULL; class_hint.res_class = NULL; gdk_error_trap_push (); XGetClassHint (xdisplay, xid, &class_hint); if (!gdk_error_trap_pop_and_print (xdisplay)) { if (class_name && class_hint.res_class && class_hint.res_class[0] != 0) *class_name = g_convert (class_hint.res_class, -1, "utf-8", "iso-8859-1", NULL, NULL, NULL); if (class_instance_name && class_hint.res_name && class_hint.res_name[0] != 0) *class_instance_name = g_convert (class_hint.res_name, -1, "utf-8", "iso-8859-1", NULL, NULL, NULL); } XFree (class_hint.res_class); XFree (class_hint.res_name); if (close_display) XCloseDisplay (xdisplay); } ./src/bamf-control.c0000644000004100000410000001720714203512426014567 0ustar www-datawww-data/* * Copyright (C) 2010-2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include #include "bamf-control.h" #include "bamf-application.h" #include "bamf-daemon.h" #include "bamf-matcher.h" struct _BamfControlPrivate { GDBusConnection *connection; guint launched_signal; GList *sources; }; G_DEFINE_TYPE_WITH_PRIVATE (BamfControl, bamf_control, BAMF_DBUS_TYPE_CONTROL_SKELETON); static void bamf_control_on_launched_callback (GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data) { BamfMatcher *matcher; const gchar *desktop_file; gint64 pid; matcher = bamf_matcher_get_default (); g_variant_get_child (parameters, 0, "^&ay", &desktop_file); g_variant_get_child (parameters, 2, "x", &pid); bamf_matcher_set_starting_desktop_file (matcher, desktop_file, NULL, TRUE); bamf_matcher_register_desktop_file_for_pid (matcher, desktop_file, pid); } static void on_bus_connection (GObject *source_object, GAsyncResult *res, gpointer user_data) { BamfControl *self; GError *error = NULL; g_return_if_fail (BAMF_IS_CONTROL (user_data)); self = BAMF_CONTROL (user_data); self->priv->connection = g_bus_get_finish (res, &error); if (error) { g_warning ("Got error when connecting to session bus: %s", error->message); g_clear_error (&error); self->priv->connection = NULL; return; } self->priv->launched_signal = g_dbus_connection_signal_subscribe (self->priv->connection, NULL, "org.gtk.gio.DesktopAppInfo", "Launched", "/org/gtk/gio/DesktopAppInfo", NULL, G_DBUS_SIGNAL_FLAGS_NONE, bamf_control_on_launched_callback, self, NULL); } static void bamf_control_constructed (GObject *object) { if (G_OBJECT_CLASS (bamf_control_parent_class)->constructed) G_OBJECT_CLASS (bamf_control_parent_class)->constructed (object); g_bus_get (G_BUS_TYPE_SESSION, NULL, on_bus_connection, object); } static gboolean on_dbus_handle_quit (BamfDBusControl *interface, GDBusMethodInvocation *invocation, BamfControl *self) { g_dbus_method_invocation_return_value (invocation, NULL); bamf_control_quit (self); return TRUE; } static gboolean on_dbus_handle_insert_desktop_file (BamfDBusControl *interface, GDBusMethodInvocation *invocation, const gchar *desktop_file, BamfControl *self) { g_dbus_method_invocation_return_value (invocation, NULL); bamf_control_insert_desktop_file (self, desktop_file); return TRUE; } static gboolean on_dbus_handle_register_application_for_pid (BamfDBusControl *interface, GDBusMethodInvocation *invocation, const gchar *application, guint pid, BamfControl *self) { g_dbus_method_invocation_return_value (invocation, NULL); bamf_control_register_application_for_pid (self, application, pid); return TRUE; } static gboolean on_dbus_handle_create_local_desktop_file (BamfDBusControl *interface, GDBusMethodInvocation *invocation, const gchar *desktop_file, BamfControl *self) { g_dbus_method_invocation_return_value (invocation, NULL); bamf_control_create_local_desktop_file (self, desktop_file); return TRUE; } static void bamf_control_init (BamfControl * self) { self->priv = bamf_control_get_instance_private (self); self->priv->sources = NULL; /* Registering signal callbacks to reply to dbus method calls */ g_signal_connect (self, "handle-quit", G_CALLBACK (on_dbus_handle_quit), self); g_signal_connect (self, "handle-om-nom-nom-desktop-file", G_CALLBACK (on_dbus_handle_insert_desktop_file), self); g_signal_connect (self, "handle-insert-desktop-file", G_CALLBACK (on_dbus_handle_insert_desktop_file), self); g_signal_connect (self, "handle-register-application-for-pid", G_CALLBACK (on_dbus_handle_register_application_for_pid), self); g_signal_connect (self, "handle-create-local-desktop-file", G_CALLBACK (on_dbus_handle_create_local_desktop_file), self); } static void bamf_control_finalize (GObject *object) { BamfControl *self = BAMF_CONTROL (object); if (self->priv->connection) { if (self->priv->launched_signal) { g_dbus_connection_signal_unsubscribe (self->priv->connection, self->priv->launched_signal); } g_object_unref (self->priv->connection); } g_list_free_full (self->priv->sources, g_object_unref); } static void bamf_control_class_init (BamfControlClass * klass) { GObjectClass *obj_class = G_OBJECT_CLASS (klass); obj_class->constructed = bamf_control_constructed; obj_class->finalize = bamf_control_finalize; } void bamf_control_register_application_for_pid (BamfControl *control, const char *application, gint32 pid) { BamfMatcher *matcher = bamf_matcher_get_default (); bamf_matcher_register_desktop_file_for_pid (matcher, application, pid); } void bamf_control_insert_desktop_file (BamfControl *control, const char *path) { BamfMatcher *matcher = bamf_matcher_get_default (); bamf_matcher_load_desktop_file (matcher, path); } void bamf_control_create_local_desktop_file (BamfControl *control, const char *app_path) { BamfMatcher *matcher; BamfView *view; g_return_if_fail (BAMF_IS_CONTROL (control)); g_return_if_fail (app_path); matcher = bamf_matcher_get_default (); view = bamf_matcher_get_view_by_path (matcher, app_path); if (BAMF_IS_APPLICATION (view)) bamf_application_create_local_desktop_file (BAMF_APPLICATION (view)); } static gboolean bamf_control_on_quit (BamfControl *control) { BamfDaemon *daemon = bamf_daemon_get_default (); bamf_daemon_stop (daemon); return FALSE; } void bamf_control_quit (BamfControl *control) { g_idle_add ((GSourceFunc) bamf_control_on_quit, control); } BamfControl * bamf_control_get_default (void) { static BamfControl *control; if (!BAMF_IS_CONTROL (control)) { control = (BamfControl *) g_object_new (BAMF_TYPE_CONTROL, NULL); } return control; } ./src/main.c0000644000004100000410000000365314203512426013130 0ustar www-datawww-data/* * Copyright (C) 2010-2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include "config.h" #include "bamf-daemon.h" #include "bamf-legacy-screen.h" #include "main.h" int main (int argc, char **argv) { BamfDaemon *daemon; GOptionContext *options; GError *error = NULL; char *state_file = NULL; gtk_init (&argc, &argv); glibtop_init (); options = g_option_context_new (""); g_option_context_set_help_enabled (options, TRUE); g_option_context_set_summary (options, "It's one, and so are we..."); GOptionEntry entries[] = { {"load-file", 'l', 0, G_OPTION_ARG_STRING, &state_file, "Load bamf state from file instead of the system", NULL }, {NULL} }; g_option_context_add_main_entries (options, entries, NULL); g_option_context_add_group (options, gtk_get_option_group (FALSE)); g_option_context_parse (options, &argc, &argv, &error); if (error) { g_print ("%s, error: %s\n", g_option_context_get_help (options, TRUE, NULL), error->message); g_clear_error (&error); exit (1); } if (state_file) { bamf_legacy_screen_set_state_file (bamf_legacy_screen_get_default (), state_file); } daemon = bamf_daemon_get_default (); bamf_daemon_start (daemon); g_object_unref (daemon); return 0; } ./src/bamf-matcher-private.h0000644000004100000410000000342614203512426016205 0ustar www-datawww-data/* * Copyright (C) 2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Marco Trevisan (Treviño) * */ #ifndef __BAMF_MATCHER_PRIVATE_H__ #define __BAMF_MATCHER_PRIVATE_H__ #include "bamf-view.h" #include "bamf-matcher.h" #include "bamf-application.h" #include "bamf-window.h" #include "bamf-legacy-window.h" struct _BamfMatcherPrivate { GArray * bad_prefixes; GArray * good_prefixes; GHashTable * desktop_id_table; GHashTable * desktop_file_table; GHashTable * desktop_class_table; GHashTable * registered_pids; GHashTable * opened_closed_paths_table; GList * known_pids; GList * views; GList * monitors; GList * favorites; GList * no_display_desktop; BamfView * active_app; BamfView * active_win; guint dispatch_changes_id; }; BamfApplication * bamf_matcher_get_application_by_desktop_file (BamfMatcher *self, const char *desktop_file); BamfApplication * bamf_matcher_get_application_by_xid (BamfMatcher *self, guint xid); char * get_exec_overridden_desktop_file (const char *exec); gboolean is_autostart_desktop_file (const gchar *desktop_file); #endif ./src/bamf-xutils.h0000644000004100000410000000231014203512426014431 0ustar www-datawww-data/* * Copyright (C) 2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> */ #ifndef __BAMF_XUTILS_H__ #define __BAMF_XUTILS_H__ #include #include #include void bamf_xutils_set_string_window_hint (Window xid, const char *atom_name, const char *value); char* bamf_xutils_get_string_window_hint (Window xid, const char *atom_name); void bamf_xutils_unset_window_hint (Window xid, const char *atom_name); void bamf_xutils_get_window_class_hints (Window xid, char **class_instance_name, char **class_name); #endif ./src/bamf-legacy-window.c0000644000004100000410000005444514203512426015665 0ustar www-datawww-data/* * Copyright (C) 2010-2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include "config.h" #include "bamf-legacy-window.h" #include "bamf-legacy-screen.h" #include "bamf-xutils.h" #include #include #include #include #include #define WNCK_WINDOW_BAMF_DATA "bamf-legacy-window" enum { NAME_CHANGED, ROLE_CHANGED, CLASS_CHANGED, STATE_CHANGED, GEOMETRY_CHANGED, CLOSED, LAST_SIGNAL, }; static guint legacy_window_signals[LAST_SIGNAL] = { 0 }; struct _BamfLegacyWindowPrivate { WnckWindow * legacy_window; GtkWidget * action_menu; GFile * mini_icon; gchar * exec_string; gchar * working_dir; gboolean is_closed; }; G_DEFINE_TYPE_WITH_PRIVATE (BamfLegacyWindow, bamf_legacy_window, G_TYPE_OBJECT); gboolean bamf_legacy_window_is_active (BamfLegacyWindow *self) { WnckWindow *active; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), FALSE); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->is_active) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->is_active (self); active = wnck_screen_get_active_window (wnck_screen_get_default ()); return active == self->priv->legacy_window; } BamfWindowType bamf_legacy_window_get_window_type (BamfLegacyWindow *self) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), 0); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_window_type) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_window_type (self); g_return_val_if_fail (self->priv->legacy_window, 0); return (BamfWindowType) wnck_window_get_window_type (self->priv->legacy_window); } gboolean bamf_legacy_window_needs_attention (BamfLegacyWindow *self) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), FALSE); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->needs_attention) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->needs_attention (self); if (!self->priv->legacy_window) return FALSE; return wnck_window_needs_attention (self->priv->legacy_window); } gboolean bamf_legacy_window_is_skip_tasklist (BamfLegacyWindow *self) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), FALSE); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->is_skip_tasklist) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->is_skip_tasklist (self); if (!self->priv->legacy_window) return FALSE; return wnck_window_is_skip_tasklist (self->priv->legacy_window); } const char * bamf_legacy_window_get_class_instance_name (BamfLegacyWindow *self) { WnckWindow *window; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); window = self->priv->legacy_window; if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_class_instance_name) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_class_instance_name (self); if (!window) return NULL; return wnck_window_get_class_instance_name (window); } const char * bamf_legacy_window_get_class_name (BamfLegacyWindow *self) { WnckWindow *window; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); window = self->priv->legacy_window; if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_class_name) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_class_name (self); if (!window) return NULL; return wnck_window_get_class_group_name (window); } const char * bamf_legacy_window_get_name (BamfLegacyWindow *self) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_name) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_name (self); if (!self->priv->legacy_window) return NULL; return wnck_window_get_name (self->priv->legacy_window); } const char * bamf_legacy_window_get_role (BamfLegacyWindow *self) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_role) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_role (self); if (!self->priv->legacy_window) return NULL; return wnck_window_get_role (self->priv->legacy_window); } char * bamf_legacy_window_get_process_name (BamfLegacyWindow *self) { gchar *stat_path; gchar *contents; gchar **lines; gchar **sections; gchar *result = NULL; guint pid; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_process_name) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_process_name (self); pid = bamf_legacy_window_get_pid (self); if (pid < 2) return NULL; stat_path = g_strdup_printf ("/proc/%i/status", pid); if (g_file_get_contents (stat_path, &contents, NULL, NULL)) { lines = g_strsplit (contents, "\n", 2); if (lines && g_strv_length (lines) > 0) { sections = g_strsplit (lines[0], "\t", 0); if (sections) { if (g_strv_length (sections) > 1) result = g_strdup (sections[1]); g_strfreev (sections); } g_strfreev (lines); } g_free (contents); } g_free (stat_path); return result; } const char * bamf_legacy_window_get_exec_string (BamfLegacyWindow *self) { guint pid; gchar **argv; glibtop_proc_args buffer; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_exec_string) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_exec_string (self); if (self->priv->exec_string) return self->priv->exec_string; pid = bamf_legacy_window_get_pid (self); if (pid == 0) return NULL; argv = glibtop_get_proc_argv (&buffer, pid, 0); self->priv->exec_string = g_strstrip (g_strjoinv (" ", argv)); g_strfreev (argv); return self->priv->exec_string; } const char * bamf_legacy_window_get_working_dir (BamfLegacyWindow *self) { guint pid = 0; gchar **dirs; glibtop_proc_wd buffer_wd; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_working_dir) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_working_dir (self); if (self->priv->working_dir) return self->priv->working_dir; pid = bamf_legacy_window_get_pid (self); if (pid == 0) return NULL; dirs = glibtop_get_proc_wd (&buffer_wd, pid); if (!dirs) return NULL; self->priv->working_dir = g_strdup (dirs[0] ? g_strstrip (dirs[0]) : NULL); g_strfreev (dirs); return self->priv->working_dir; } char * bamf_legacy_window_save_mini_icon (BamfLegacyWindow *self) { WnckWindow *window; GdkPixbuf *pbuf; GFile *tmp; GFileIOStream *iostream; GOutputStream *output; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->save_mini_icon) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->save_mini_icon (self); if (self->priv->mini_icon) { if (g_file_query_exists (self->priv->mini_icon, NULL)) { return g_file_get_path (self->priv->mini_icon); } else { g_object_unref (self->priv->mini_icon); self->priv->mini_icon = NULL; } } window = self->priv->legacy_window; if (!window) return NULL; if (wnck_window_get_icon_is_fallback (window)) return NULL; tmp = g_file_new_tmp (".bamficonXXXXXX", &iostream, NULL); if (!tmp) return NULL; output = g_io_stream_get_output_stream (G_IO_STREAM (iostream)); pbuf = wnck_window_get_icon (window); if (gdk_pixbuf_save_to_stream (pbuf, output, "png", NULL, NULL, NULL)) { self->priv->mini_icon = g_object_ref (tmp); } g_object_unref (iostream); g_object_unref (tmp); return g_file_get_path (self->priv->mini_icon); } GFile * bamf_legacy_window_get_saved_mini_icon (BamfLegacyWindow *self) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); return self->priv->mini_icon; } guint bamf_legacy_window_get_pid (BamfLegacyWindow *self) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), 0); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_pid) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_pid (self); if (!self->priv->legacy_window) return 0; int pid = wnck_window_get_pid (self->priv->legacy_window); return G_LIKELY (pid >= 0) ? pid : 0; } guint32 bamf_legacy_window_get_xid (BamfLegacyWindow *self) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), 0); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_xid) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_xid (self); if (!self->priv->legacy_window) return 0; return (guint32) wnck_window_get_xid (self->priv->legacy_window); } BamfLegacyWindow * bamf_legacy_window_get_transient (BamfLegacyWindow *self) { BamfLegacyScreen *screen; BamfLegacyWindow *other; GList *windows, *l; WnckWindow *transient_legacy; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_transient) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_transient (self); g_return_val_if_fail (self->priv->legacy_window, NULL); transient_legacy = wnck_window_get_transient (self->priv->legacy_window); screen = bamf_legacy_screen_get_default (); g_return_val_if_fail (BAMF_IS_LEGACY_SCREEN (screen), NULL); windows = bamf_legacy_screen_get_windows (screen); for (l = windows; l; l = l->next) { other = l->data; if (!BAMF_IS_LEGACY_WINDOW (other)) continue; if (other->priv->legacy_window == transient_legacy) return other; } return NULL; } gint bamf_legacy_window_get_stacking_position (BamfLegacyWindow *self) { BamfLegacyScreen *screen; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), -1); screen = bamf_legacy_screen_get_default (); g_return_val_if_fail (BAMF_IS_LEGACY_SCREEN (screen), -1); return g_list_index (bamf_legacy_screen_get_windows (screen), self); } static void handle_window_signal (WnckWindow *window, gpointer data) { BamfLegacyWindow *self = g_object_get_data (G_OBJECT (window), WNCK_WINDOW_BAMF_DATA); g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); g_signal_emit (self, legacy_window_signals[GPOINTER_TO_UINT (data)], 0); } static void handle_state_changed (WnckWindow *window, WnckWindowState change_mask, WnckWindowState new_state, BamfLegacyWindow *self) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); g_signal_emit (self, legacy_window_signals[STATE_CHANGED], 0); } gboolean bamf_legacy_window_is_closed (BamfLegacyWindow *self) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), TRUE); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->is_closed) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->is_closed (self); return self->priv->is_closed; } void bamf_legacy_window_get_geometry (BamfLegacyWindow *self, gint *x, gint *y, gint *width, gint *height) { if (x) *x = 0; if (y) *y = 0; if (width) *width = 0; if (height) *height = 0; g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_app_id) BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_app_id (self); if (!self->priv->legacy_window) return; wnck_window_get_geometry (self->priv->legacy_window, x, y, width, height); } BamfWindowMaximizationType bamf_legacy_window_maximized (BamfLegacyWindow *self) { WnckWindowState window_state; BamfWindowMaximizationType maximization_type; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), BAMF_WINDOW_FLOATING); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->maximized) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->maximized (self); if (!self->priv->legacy_window) return BAMF_WINDOW_FLOATING; window_state = wnck_window_get_state (self->priv->legacy_window); gboolean vertical = (window_state & WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY); gboolean horizontal = (window_state & WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY); if (vertical && horizontal) { maximization_type = BAMF_WINDOW_MAXIMIZED; } else if (horizontal) { maximization_type = BAMF_WINDOW_HORIZONTAL_MAXIMIZED; } else if (vertical) { maximization_type = BAMF_WINDOW_VERTICAL_MAXIMIZED; } else { maximization_type = BAMF_WINDOW_FLOATING; } return maximization_type; } char * bamf_legacy_window_get_hint (BamfLegacyWindow *self, const char *name) { g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); g_return_val_if_fail (name, NULL); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_hint) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_hint (self, name); g_return_val_if_fail (WNCK_IS_WINDOW (self->priv->legacy_window), NULL); guint xid = bamf_legacy_window_get_xid (self); return bamf_xutils_get_string_window_hint (xid, name); } void bamf_legacy_window_set_hint (BamfLegacyWindow *self, const char *name, const char *value) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); g_return_if_fail (name); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->set_hint) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->set_hint (self, name, value); g_return_if_fail (WNCK_IS_WINDOW (self->priv->legacy_window)); guint xid = bamf_legacy_window_get_xid (self); bamf_xutils_set_string_window_hint (xid, name, value); } static void top_window_action_menu (GtkMenu *menu, gint *x, gint *y, gboolean *push, gpointer data) { BamfLegacyWindow *self = data; gint w, h, scale; scale = gdk_screen_get_monitor_scale_factor (gdk_screen_get_default (), 0); scale = !scale ? 1: scale; wnck_window_get_client_window_geometry (self->priv->legacy_window, x, y, &w, &h); *x /= scale; *y /= scale; *push = TRUE; } GtkWidget * bamf_legacy_window_get_action_menu (BamfLegacyWindow *self) { BamfLegacyWindowPrivate *priv; g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_action_menu) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_action_menu (self); priv = self->priv; g_return_val_if_fail (WNCK_IS_WINDOW (priv->legacy_window), NULL); if (!priv->action_menu) { priv->action_menu = wnck_action_menu_new (priv->legacy_window); g_object_add_weak_pointer (G_OBJECT (priv->action_menu), (gpointer *) &priv->action_menu); } return priv->action_menu; } void bamf_legacy_window_show_action_menu (BamfLegacyWindow *self, guint32 time, guint button, gint x, gint y) { BamfLegacyWindowPrivate *priv; GtkWidget *menu; g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->show_action_menu) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->show_action_menu (self, button, time, x, y); g_return_if_fail (WNCK_IS_WINDOW (self->priv->legacy_window)); priv = self->priv; if (priv->action_menu && gtk_widget_is_visible (GTK_WIDGET (priv->action_menu))) return; menu = bamf_legacy_window_get_action_menu (self); g_object_ref_sink (menu); g_signal_handlers_disconnect_by_func (menu, g_object_unref, self); g_signal_connect (G_OBJECT (menu), "unmap", G_CALLBACK (g_object_unref), self); gtk_menu_set_screen (GTK_MENU (menu), gdk_screen_get_default ()); gtk_widget_show (menu); GtkMenuPositionFunc position = button ? NULL : top_window_action_menu; gtk_menu_popup (GTK_MENU (menu), NULL, NULL, position, self, button, time); } static void handle_window_closed (WnckScreen *screen, WnckWindow *window, BamfLegacyWindow *self) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); g_return_if_fail (WNCK_IS_WINDOW (window)); if (self->priv->legacy_window == window) { self->priv->is_closed = TRUE; g_signal_emit (self, legacy_window_signals[CLOSED], 0); } } static void handle_destroy_notify (gpointer *data, BamfLegacyWindow *self_was_here) { BamfLegacyScreen *screen = bamf_legacy_screen_get_default (); bamf_legacy_screen_inject_window (screen, GPOINTER_TO_UINT (data)); } /* This utility function allows to set a BamfLegacyWindow as closed, notifying * all its owners, and to reopen it once the current window has been destroyed. * This allows to remap particular windows to different applications. */ void bamf_legacy_window_reopen (BamfLegacyWindow *self) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->reopen) return BAMF_LEGACY_WINDOW_GET_CLASS (self)->reopen (self); g_return_if_fail (WNCK_IS_WINDOW (self->priv->legacy_window)); guint xid = bamf_legacy_window_get_xid (self); /* Adding a weak ref to this object, causes to get notified after the object * destruction, so once this BamfLegacyWindow has been closed and destroyed * the handle_destroy_notify() function will be called, and that will * provide to inject another window like this one to the BamfLegacyScreen */ g_object_weak_ref (G_OBJECT (self), (GWeakNotify) handle_destroy_notify, GUINT_TO_POINTER (xid)); self->priv->is_closed = TRUE; g_signal_emit (self, legacy_window_signals[CLOSED], 0); } static void bamf_legacy_window_dispose (GObject *object) { BamfLegacyWindow *self; guint i; self = BAMF_LEGACY_WINDOW (object); if (self->priv->mini_icon) { g_file_delete (self->priv->mini_icon, NULL, NULL); g_clear_object (&self->priv->mini_icon); } g_clear_pointer (&self->priv->exec_string, g_free); g_clear_pointer (&self->priv->working_dir, g_free); g_signal_handlers_disconnect_by_data (wnck_screen_get_default (), self); if (self->priv->legacy_window) { g_object_set_data (G_OBJECT (self->priv->legacy_window), WNCK_WINDOW_BAMF_DATA, NULL); g_signal_handlers_disconnect_by_data (self->priv->legacy_window, self); for (i = 0; i < LAST_SIGNAL; ++i) { g_signal_handlers_disconnect_by_func (self->priv->legacy_window, handle_window_signal, GUINT_TO_POINTER (NAME_CHANGED)); } self->priv->legacy_window = NULL; } if (self->priv->action_menu) { g_signal_handlers_disconnect_by_data (self->priv->action_menu, self); g_object_remove_weak_pointer (G_OBJECT (self->priv->action_menu), (gpointer*) &self->priv->action_menu); } G_OBJECT_CLASS (bamf_legacy_window_parent_class)->dispose (object); } static void bamf_legacy_window_init (BamfLegacyWindow * self) { self->priv = bamf_legacy_window_get_instance_private (self); g_signal_connect (wnck_screen_get_default (), "window-closed", (GCallback) handle_window_closed, self); } static void bamf_legacy_window_class_init (BamfLegacyWindowClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = bamf_legacy_window_dispose; legacy_window_signals [NAME_CHANGED] = g_signal_new (BAMF_LEGACY_WINDOW_SIGNAL_NAME_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyWindowClass, name_changed), NULL, NULL, NULL, G_TYPE_NONE, 0); legacy_window_signals [ROLE_CHANGED] = g_signal_new (BAMF_LEGACY_WINDOW_SIGNAL_ROLE_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyWindowClass, role_changed), NULL, NULL, NULL, G_TYPE_NONE, 0); legacy_window_signals [CLASS_CHANGED] = g_signal_new (BAMF_LEGACY_WINDOW_SIGNAL_CLASS_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyWindowClass, class_changed), NULL, NULL, NULL, G_TYPE_NONE, 0); legacy_window_signals [STATE_CHANGED] = g_signal_new (BAMF_LEGACY_WINDOW_SIGNAL_STATE_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyWindowClass, state_changed), NULL, NULL, NULL, G_TYPE_NONE, 0); legacy_window_signals [GEOMETRY_CHANGED] = g_signal_new (BAMF_LEGACY_WINDOW_SIGNAL_GEOMETRY_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyWindowClass, geometry_changed), NULL, NULL, NULL, G_TYPE_NONE, 0); legacy_window_signals [CLOSED] = g_signal_new (BAMF_LEGACY_WINDOW_SIGNAL_CLOSED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyWindowClass, closed), NULL, NULL, NULL, G_TYPE_NONE, 0); } BamfLegacyWindow * bamf_legacy_window_new (WnckWindow *legacy_window) { BamfLegacyWindow *self; self = (BamfLegacyWindow *) g_object_new (BAMF_TYPE_LEGACY_WINDOW, NULL); self->priv->legacy_window = legacy_window; g_return_val_if_fail (WNCK_IS_WINDOW (self->priv->legacy_window), self); g_warn_if_fail (!g_object_get_data (G_OBJECT (legacy_window), WNCK_WINDOW_BAMF_DATA)); g_object_set_data (G_OBJECT (legacy_window), WNCK_WINDOW_BAMF_DATA, self); g_signal_connect (G_OBJECT (legacy_window), "name-changed", G_CALLBACK (handle_window_signal), GUINT_TO_POINTER (NAME_CHANGED)); g_signal_connect (G_OBJECT (legacy_window), "role-changed", G_CALLBACK (handle_window_signal), GUINT_TO_POINTER (ROLE_CHANGED)); g_signal_connect (G_OBJECT (legacy_window), "class-changed", G_CALLBACK (handle_window_signal), GUINT_TO_POINTER (CLASS_CHANGED)); g_signal_connect (G_OBJECT (legacy_window), "geometry-changed", G_CALLBACK (handle_window_signal), GUINT_TO_POINTER (GEOMETRY_CHANGED)); g_signal_connect (G_OBJECT (legacy_window), "state-changed", G_CALLBACK (handle_state_changed), self); return self; } ./src/bamf-legacy-screen.c0000644000004100000410000004713514203512426015633 0ustar www-datawww-data/* * Copyright (C) 2010 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * */ #include "bamf-legacy-screen.h" #include "bamf-legacy-screen-private.h" #include #include #define SN_API_NOT_YET_FROZEN #include #undef SN_API_NOT_YET_FROZEN static BamfLegacyScreen *static_screen = NULL; enum { WINDOW_OPENING, WINDOW_OPENING_COMPLETED, WINDOW_OPENING_CANCELED, WINDOW_OPENED, WINDOW_CLOSED, STACKING_CHANGED, ACTIVE_WINDOW_CHANGED, LAST_SIGNAL, }; static guint legacy_screen_signals[LAST_SIGNAL] = { 0 }; static Atom _COMPIZ_TOOLKIT_ACTION = 0; static Atom _COMPIZ_TOOLKIT_ACTION_WINDOW_MENU = 0; struct _BamfLegacyScreenPrivate { WnckScreen * legacy_screen; SnDisplay * sn_display; SnMonitorContext * sn_monitor_context; GList *windows; GFile *file; GDataInputStream *stream; }; G_DEFINE_TYPE_WITH_PRIVATE (BamfLegacyScreen, bamf_legacy_screen, G_TYPE_OBJECT); static void handle_window_closed (BamfLegacyWindow *window, BamfLegacyScreen *self) { self->priv->windows = g_list_remove (self->priv->windows, window); g_signal_emit (self, legacy_screen_signals[WINDOW_CLOSED], 0, window); g_object_unref (window); } static gboolean on_state_file_load_timeout (BamfLegacyScreen *self) { BamfLegacyWindow *window; GDataInputStream *stream; gchar *line, *name, *class, *exec; GList *l; gchar **parts; gsize parts_size; guint32 xid; g_return_val_if_fail (BAMF_IS_LEGACY_SCREEN (self), FALSE); stream = self->priv->stream; line = g_data_input_stream_read_line (stream, NULL, NULL, NULL); if (!line) return FALSE; // Line format: // open // close // attention // skip // geometry // maximized parts = g_strsplit (line, "\t", 0); g_free (line); parts_size = 0; while (parts[parts_size] != NULL) parts_size++; if (parts_size < 2) return FALSE; xid = (guint32) atol (parts[1]); if (g_strcmp0 (parts[0], "open") == 0 && parts_size == 5) { name = parts[2]; class = parts[3]; exec = parts[4]; BamfLegacyWindowTest *test_win = bamf_legacy_window_test_new (xid, name, class, exec); _bamf_legacy_screen_open_test_window (self, test_win); } else if (g_strcmp0 (parts[0], "close") == 0 && parts_size == 2) { for (l = self->priv->windows; l; l = l->next) { window = l->data; if (bamf_legacy_window_get_xid (window) == xid) { _bamf_legacy_screen_close_test_window (self, BAMF_LEGACY_WINDOW_TEST (window)); break; } } } else if (g_strcmp0 (parts[0], "attention") == 0 && parts_size == 3) { gboolean attention = FALSE; if (g_strcmp0 (parts[2], "true") == 0) attention = TRUE; else if (g_strcmp0 (parts[2], "false") == 0) attention = FALSE; else return TRUE; for (l = self->priv->windows; l; l = l->next) { if (bamf_legacy_window_get_xid (l->data) == xid) { bamf_legacy_window_test_set_attention (l->data, attention); break; } } } else if (g_strcmp0 (parts[0], "skip") == 0 && parts_size == 3) { gboolean skip = FALSE; if (g_strcmp0 (parts[2], "true") == 0) skip = TRUE; else if (g_strcmp0 (parts[2], "false") == 0) skip = FALSE; else return TRUE; for (l = self->priv->windows; l; l = l->next) { if (bamf_legacy_window_get_xid (l->data) == xid) { bamf_legacy_window_test_set_skip (l->data, skip); break; } } } else if (g_strcmp0 (parts[0], "geometry") == 0 && parts_size == 6) { int x = atoi (parts[2]); int y = atoi (parts[3]); int width = atoi (parts[4]); int height = atoi (parts[5]); for (l = self->priv->windows; l; l = l->next) { if (bamf_legacy_window_get_xid (l->data) == xid) { bamf_legacy_window_test_set_geometry (l->data, x, y, width, height); break; } } } else if (g_strcmp0 (parts[0], "maximized") == 0 && parts_size == 3) { BamfWindowMaximizationType maximized; if (g_strcmp0 (parts[2], "maximized") == 0) maximized = BAMF_WINDOW_MAXIMIZED; else if (g_strcmp0 (parts[2], "vmaximized") == 0) maximized = BAMF_WINDOW_VERTICAL_MAXIMIZED; else if (g_strcmp0 (parts[2], "hmaximized") == 0) maximized = BAMF_WINDOW_HORIZONTAL_MAXIMIZED; else if (g_strcmp0 (parts[2], "floating") == 0) maximized = BAMF_WINDOW_FLOATING; else return TRUE; for (l = self->priv->windows; l; l = l->next) { if (bamf_legacy_window_get_xid (l->data) == xid) { bamf_legacy_window_test_set_maximized (l->data, maximized); break; } } } else { g_warning ("Could not parse line\n"); } g_strfreev (parts); return TRUE; } static gint compare_windows_by_stack_order (gconstpointer a, gconstpointer b, gpointer data) { BamfLegacyScreen *self; GList *l; guint xid_a, xid_b; g_return_val_if_fail (BAMF_IS_LEGACY_SCREEN (data), 1); self = BAMF_LEGACY_SCREEN (data); xid_a = bamf_legacy_window_get_xid (BAMF_LEGACY_WINDOW (a)); xid_b = bamf_legacy_window_get_xid (BAMF_LEGACY_WINDOW (b)); for (l = wnck_screen_get_windows_stacked (self->priv->legacy_screen); l; l = l->next) { gulong legacy_xid = wnck_window_get_xid (WNCK_WINDOW (l->data)); if (legacy_xid == xid_a) return -1; if (legacy_xid == xid_b) return 1; } return 0; } static void handle_sn_monitor_event (SnMonitorEvent *event, void *data) { BamfLegacyScreen *self = data; switch (sn_monitor_event_get_type (event)) { case SN_MONITOR_EVENT_INITIATED: case SN_MONITOR_EVENT_CHANGED: { SnStartupSequence *sequence = sn_monitor_event_get_startup_sequence (event); const gchar *app_id = sn_startup_sequence_get_application_id (sequence); g_signal_emit (self, legacy_screen_signals[WINDOW_OPENING], 0, app_id, sequence); } break; case SN_MONITOR_EVENT_COMPLETED: { SnStartupSequence *sequence = sn_monitor_event_get_startup_sequence (event); const gchar *app_id = sn_startup_sequence_get_application_id (sequence); g_signal_emit (self, legacy_screen_signals[WINDOW_OPENING_COMPLETED], 0, app_id); break; } case SN_MONITOR_EVENT_CANCELED: { SnStartupSequence *sequence = sn_monitor_event_get_startup_sequence (event); const gchar *app_id = sn_startup_sequence_get_application_id (sequence); g_signal_emit (self, legacy_screen_signals[WINDOW_OPENING_CANCELED], 0, app_id); break; } } } static void handle_window_opened (WnckScreen *screen, WnckWindow *window, BamfLegacyScreen *legacy) { BamfLegacyWindow *legacy_window; g_return_if_fail (WNCK_IS_WINDOW (window)); legacy_window = bamf_legacy_window_new (window); g_signal_connect (G_OBJECT (legacy_window), "closed", (GCallback) handle_window_closed, legacy); legacy->priv->windows = g_list_insert_sorted_with_data (legacy->priv->windows, legacy_window, compare_windows_by_stack_order, legacy); g_signal_emit (legacy, legacy_screen_signals[WINDOW_OPENED], 0, legacy_window); } static void handle_stacking_changed (WnckScreen *screen, BamfLegacyScreen *legacy) { legacy->priv->windows = g_list_sort_with_data (legacy->priv->windows, compare_windows_by_stack_order, legacy); g_signal_emit (legacy, legacy_screen_signals[STACKING_CHANGED], 0); } /* This function allows to push into the screen a window by its xid. * If the window is already known, it's just ignored, otherwise it gets added * to the windows list. The BamfLegacyScreen should automatically update its * windows list when they are added/removed from the screen, but if a child * BamfLegacyWindow is closed, then it could be possible to re-add it. */ void bamf_legacy_screen_inject_window (BamfLegacyScreen *self, guint xid) { g_return_if_fail (BAMF_IS_LEGACY_SCREEN (self)); BamfLegacyWindow *window; GList *l; for (l = self->priv->windows; l; l = l->next) { window = l->data; if (bamf_legacy_window_get_xid (window) == xid) { return; } } WnckWindow *legacy_window = wnck_window_get (xid); if (WNCK_IS_WINDOW (legacy_window)) { handle_window_opened (NULL, legacy_window, self); } } void bamf_legacy_screen_set_state_file (BamfLegacyScreen *self, const char *file) { GFile *gfile; GDataInputStream *stream; g_return_if_fail (BAMF_IS_LEGACY_SCREEN (self)); // Disconnect our handlers so we can work purely on the file g_signal_handlers_disconnect_by_func (self->priv->legacy_screen, handle_window_opened, self); g_signal_handlers_disconnect_by_func (self->priv->legacy_screen, handle_window_closed, self); g_signal_handlers_disconnect_by_func (self->priv->legacy_screen, handle_stacking_changed, self); gfile = g_file_new_for_path (file); if (!file) { g_error ("Could not open file %s", file); } stream = g_data_input_stream_new (G_INPUT_STREAM (g_file_read (gfile, NULL, NULL))); if (!stream) { g_error ("Could not open file stream for %s", file); } self->priv->file = gfile; self->priv->stream = stream; g_timeout_add (500, (GSourceFunc) on_state_file_load_timeout, self); } GList * bamf_legacy_screen_get_windows (BamfLegacyScreen *screen) { g_return_val_if_fail (BAMF_IS_LEGACY_SCREEN (screen), NULL); return screen->priv->windows; } BamfLegacyWindow * bamf_legacy_screen_get_active_window (BamfLegacyScreen *screen) { BamfLegacyWindow *window; GList *l; g_return_val_if_fail (BAMF_IS_LEGACY_SCREEN (screen), NULL); for (l = screen->priv->windows; l; l = l->next) { window = l->data; if (bamf_legacy_window_is_active (window)) return window; } return NULL; } static BamfLegacyWindow * bamf_legacy_screen_get_window_by_xid (BamfLegacyScreen *screen, Window xid) { BamfLegacyWindow *window; GList *l; g_return_val_if_fail (BAMF_IS_LEGACY_SCREEN (screen), NULL); for (l = screen->priv->windows; l; l = l->next) { window = l->data; if (bamf_legacy_window_get_xid (window) == xid) return window; } return NULL; } static void handle_active_window_changed (WnckScreen *screen, WnckWindow *previous, BamfLegacyScreen *self) { g_return_if_fail (BAMF_IS_LEGACY_SCREEN (self)); g_signal_emit (self, legacy_screen_signals[ACTIVE_WINDOW_CHANGED], 0); } static void bamf_legacy_screen_finalize (GObject *object) { BamfLegacyScreen *self = BAMF_LEGACY_SCREEN (object); if (self->priv->sn_display) { sn_display_unref (self->priv->sn_display); self->priv->sn_display = NULL; } if (self->priv->sn_monitor_context) { sn_monitor_context_unref (self->priv->sn_monitor_context); self->priv->sn_monitor_context = NULL; } if (self->priv->windows) g_list_free_full (self->priv->windows, g_object_unref); if (self->priv->file) g_object_unref (self->priv->file); if (self->priv->stream) g_object_unref (self->priv->stream); wnck_shutdown (); static_screen = NULL; G_OBJECT_CLASS (bamf_legacy_screen_parent_class)->finalize (object); } static void bamf_legacy_screen_init (BamfLegacyScreen * self) { self->priv = bamf_legacy_screen_get_instance_private (self); } static void bamf_legacy_screen_class_init (BamfLegacyScreenClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = bamf_legacy_screen_finalize; legacy_screen_signals [WINDOW_OPENING] = g_signal_new (BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENING, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyScreenClass, window_opening), NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_POINTER); legacy_screen_signals [WINDOW_OPENING_COMPLETED] = g_signal_new (BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENING_COMPLETED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyScreenClass, window_opening_completed), NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING); legacy_screen_signals [WINDOW_OPENING_CANCELED] = g_signal_new (BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENING_CANCELED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyScreenClass, window_opening_canceled), NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING); legacy_screen_signals [WINDOW_OPENED] = g_signal_new (BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_OPENED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyScreenClass, window_opened), NULL, NULL, NULL, G_TYPE_NONE, 1, BAMF_TYPE_LEGACY_WINDOW); legacy_screen_signals [WINDOW_CLOSED] = g_signal_new (BAMF_LEGACY_SCREEN_SIGNAL_WINDOW_CLOSED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyScreenClass, window_closed), NULL, NULL, NULL, G_TYPE_NONE, 1, BAMF_TYPE_LEGACY_WINDOW); legacy_screen_signals [STACKING_CHANGED] = g_signal_new (BAMF_LEGACY_SCREEN_SIGNAL_STACKING_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyScreenClass, stacking_changed), NULL, NULL, NULL, G_TYPE_NONE, 0); legacy_screen_signals [ACTIVE_WINDOW_CHANGED] = g_signal_new (BAMF_LEGACY_SCREEN_SIGNAL_ACTIVE_WINDOW_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfLegacyScreenClass, active_window_changed), NULL, NULL, NULL, G_TYPE_NONE, 0); } #include GdkFilterReturn filter_compiz_messages(GdkXEvent *gdkxevent, GdkEvent *event, gpointer data) { BamfLegacyScreen *self = data; BamfLegacyWindow *window; XEvent *xevent = gdkxevent; if (xevent->type == ClientMessage) { if (sn_display_process_event (self->priv->sn_display, xevent)) { return GDK_FILTER_REMOVE; } if (xevent->xclient.message_type == _COMPIZ_TOOLKIT_ACTION) { Atom msg = xevent->xclient.data.l[0]; if (msg == _COMPIZ_TOOLKIT_ACTION_WINDOW_MENU) { window = bamf_legacy_screen_get_window_by_xid (self, xevent->xany.window); if (BAMF_IS_LEGACY_WINDOW (window) && bamf_legacy_window_get_window_type(window) != BAMF_WINDOW_DESKTOP) { Time time = xevent->xclient.data.l[1]; int button = xevent->xclient.data.l[2]; int x = xevent->xclient.data.l[3]; int y = xevent->xclient.data.l[4]; bamf_legacy_window_show_action_menu (window, time, button, x, y); return GDK_FILTER_REMOVE; } } } } return GDK_FILTER_CONTINUE; } BamfLegacyScreen * bamf_legacy_screen_get_default () { BamfLegacyScreen *self; Display *dpy; gchar **current_desktops = NULL; const gchar *xdg_current_desktop; if (static_screen) return static_screen; self = (BamfLegacyScreen *) g_object_new (BAMF_TYPE_LEGACY_SCREEN, NULL); static_screen = self; if (g_strcmp0 (g_getenv ("BAMF_TEST_MODE"), "TRUE") == 0) return static_screen; wnck_set_default_icon_size (BAMF_DEFAULT_ICON_SIZE); wnck_set_default_mini_icon_size (BAMF_DEFAULT_MINI_ICON_SIZE); self->priv->legacy_screen = wnck_screen_get_default (); dpy = gdk_x11_get_default_xdisplay (); self->priv->sn_display = sn_display_new (dpy, NULL, NULL); self->priv->sn_monitor_context = sn_monitor_context_new (self->priv->sn_display, DefaultScreen (dpy), handle_sn_monitor_event, self, NULL); g_signal_connect (G_OBJECT (self->priv->legacy_screen), "window-opened", (GCallback) handle_window_opened, self); g_signal_connect (G_OBJECT (self->priv->legacy_screen), "window-stacking-changed", (GCallback) handle_stacking_changed, self); g_signal_connect (G_OBJECT (self->priv->legacy_screen), "active-window-changed", (GCallback) handle_active_window_changed, self); xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); if (xdg_current_desktop) current_desktops = g_strsplit (xdg_current_desktop, ":", 0); if (current_desktops && g_strv_contains ((const gchar * const *) current_desktops, "Unity")) { _COMPIZ_TOOLKIT_ACTION = XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION", False); _COMPIZ_TOOLKIT_ACTION_WINDOW_MENU = XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", False); gdk_window_add_filter (NULL, filter_compiz_messages, self); } g_strfreev (current_desktops); return static_screen; } // Private functions for testing purposes void _bamf_legacy_screen_open_test_window (BamfLegacyScreen *self, BamfLegacyWindowTest *test_window) { GList *l; BamfLegacyWindow *window; guint xid; g_return_if_fail (BAMF_IS_LEGACY_SCREEN (self)); g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (test_window)); window = BAMF_LEGACY_WINDOW (test_window); xid = bamf_legacy_window_get_xid (window); for (l = self->priv->windows; l; l = l->next) { if (bamf_legacy_window_get_xid (BAMF_LEGACY_WINDOW (l->data)) == xid) { return; } } self->priv->windows = g_list_append (self->priv->windows, window); g_signal_emit (self, legacy_screen_signals[STACKING_CHANGED], 0); g_signal_connect (G_OBJECT (window), "closed", (GCallback) handle_window_closed, self); g_signal_emit (self, legacy_screen_signals[WINDOW_OPENED], 0, window); } void _bamf_legacy_screen_close_test_window (BamfLegacyScreen *self, BamfLegacyWindowTest *test_window) { g_return_if_fail (BAMF_IS_LEGACY_SCREEN (self)); g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (test_window)); // This will cause handle_window_closed to be called bamf_legacy_window_test_close (BAMF_LEGACY_WINDOW_TEST (test_window)); } ./src/bamf-view.c0000644000004100000410000007461314203512426014065 0ustar www-datawww-data/* * Copyright (C) 2010-2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include "bamf-view.h" static void bamf_view_dbus_view_iface_init (BamfDBusItemViewIface *iface); #define STARTING_MAX_WAIT 15 enum { PROP_0, PROP_NAME, PROP_ICON, PROP_ACTIVE, PROP_STARTING, PROP_RUNNING, PROP_URGENT, PROP_USER_VISIBLE, }; enum { CLOSED_INTERNAL, EXPORTED, LAST_SIGNAL, }; static guint view_signals[LAST_SIGNAL] = { 0 }; typedef struct _BamfViewPropCache { /* FIXME: temporary cache these properties until we don't export the view * to the bus, we need this until the skeleton won't be smart enough to emit * signals as soon as the object is exported */ gboolean starting; gboolean running; gboolean user_visible; gboolean urgent; gboolean active; gchar *name; gchar *icon; } BamfViewPropCache; struct _BamfViewPrivate { BamfDBusItemView * dbus_iface; BamfViewPropCache * props; char * path; GList * children; GList * parents; gboolean closed; guint starting_timeout; SnStartupSequence *startup_sequence; /* FIXME: remove this as soon as we move to properties on library as well */ guint active_changed_idle; }; G_DEFINE_TYPE_WITH_CODE (BamfView, bamf_view, BAMF_DBUS_ITEM_TYPE_OBJECT_SKELETON, G_ADD_PRIVATE(BamfView) G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_VIEW, bamf_view_dbus_view_iface_init)); static gboolean on_active_changed_idle (gpointer data) { g_return_val_if_fail (BAMF_IS_VIEW (data), FALSE); BamfView *self = BAMF_VIEW (data); gboolean active = bamf_view_is_active (self); self->priv->active_changed_idle = 0; g_signal_emit_by_name (self, "active-changed", active); return FALSE; } static void bamf_view_active_changed (BamfView *view, gboolean active) { g_return_if_fail (BAMF_IS_VIEW (view)); gboolean emit = TRUE; if (BAMF_VIEW_GET_CLASS (view)->active_changed) { emit = !BAMF_VIEW_GET_CLASS (view)->active_changed (view, active); } if (emit) { if (view->priv->active_changed_idle) g_source_remove (view->priv->active_changed_idle); guint idle = g_idle_add_full (G_PRIORITY_DEFAULT, on_active_changed_idle, view, NULL); view->priv->active_changed_idle = idle; } if (active) bamf_view_set_starting (view, NULL, FALSE); } static void bamf_view_name_changed (BamfView *view, const gchar *new_name) { g_return_if_fail (BAMF_IS_VIEW (view)); const gchar *old_name = bamf_view_get_name (view); g_signal_emit_by_name (view, "name-changed", old_name, new_name); } static void bamf_view_icon_changed (BamfView *view, const gchar *new_icon) { g_object_notify (G_OBJECT (view), "icon"); } static void bamf_view_user_visible_changed (BamfView *view, gboolean user_visible) { g_return_if_fail (BAMF_IS_VIEW (view)); gboolean emit = TRUE; if (BAMF_VIEW_GET_CLASS (view)->user_visible_changed) { emit = !BAMF_VIEW_GET_CLASS (view)->user_visible_changed (view, user_visible); } if (emit) g_signal_emit_by_name (view, "user-visible-changed", user_visible); } static gboolean on_starting_timeout (gpointer data) { BamfView *view = data; view->priv->starting_timeout = 0; bamf_view_set_starting (view, NULL, FALSE); return FALSE; } static void bamf_view_starting_changed (BamfView *view, gboolean starting) { BamfViewPrivate *priv; g_return_if_fail (BAMF_IS_VIEW (view)); priv = view->priv; if (BAMF_VIEW_GET_CLASS (view)->starting_changed) { BAMF_VIEW_GET_CLASS (view)->starting_changed (view, starting); } if (priv->starting_timeout) { g_source_remove (priv->starting_timeout); priv->starting_timeout = 0; } if (starting) priv->starting_timeout = g_timeout_add_seconds (STARTING_MAX_WAIT, on_starting_timeout, view); } static void bamf_view_running_changed (BamfView *view, gboolean running) { g_return_if_fail (BAMF_IS_VIEW (view)); gboolean emit = TRUE; if (BAMF_VIEW_GET_CLASS (view)->running_changed) { emit = !BAMF_VIEW_GET_CLASS (view)->running_changed (view, running); } if (emit) g_signal_emit_by_name (view, "running-changed", running); if (running) bamf_view_set_starting (view, NULL, FALSE); } static void bamf_view_urgent_changed (BamfView *view, gboolean urgent) { g_return_if_fail (BAMF_IS_VIEW (view)); gboolean emit = TRUE; if (BAMF_VIEW_GET_CLASS (view)->urgent_changed) { emit = !BAMF_VIEW_GET_CLASS (view)->urgent_changed (view, urgent); } if (emit) g_signal_emit_by_name (view, "urgent-changed", urgent); if (urgent) bamf_view_set_starting (view, NULL, FALSE); } void bamf_view_close (BamfView *view) { BamfViewPrivate *priv; gboolean emit = TRUE; GList *l; g_return_if_fail (BAMF_IS_VIEW (view)); priv = view->priv; if (priv->closed) return; priv->closed = TRUE; if (BAMF_VIEW_GET_CLASS (view)->closed) { emit = !BAMF_VIEW_GET_CLASS (view)->closed (view); } if (priv->children) { for (l = priv->children; l; l = l->next) { if (BAMF_IS_VIEW (l->data)) bamf_view_remove_child (view, l->data); } g_list_free (priv->children); priv->children = NULL; } if (emit) { g_object_ref (view); g_signal_emit (view, view_signals[CLOSED_INTERNAL], 0); g_signal_emit_by_name (view, "closed"); g_object_unref (view); } } const char * bamf_view_get_path (BamfView *view) { g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); return view->priv->path; } GVariant * bamf_view_get_children_paths (BamfView *view) { GVariantBuilder b; GList *l; g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); for (l = view->priv->children; l; l = l->next) { BamfView *child = l->data; const char *path = bamf_view_get_path (child); if (!path) continue; g_variant_builder_add (&b, "s", path); } g_variant_builder_close (&b); return g_variant_builder_end (&b); } GList * bamf_view_get_children (BamfView *view) { g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); return view->priv->children; } GVariant * bamf_view_get_parent_paths (BamfView *view) { GVariantBuilder b; GList *l; g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)")); g_variant_builder_open (&b, G_VARIANT_TYPE ("as")); for (l = view->priv->parents; l; l = l->next) { BamfView *parent = l->data; const char *path = bamf_view_get_path (parent); if (!path) continue; g_variant_builder_add (&b, "s", path); } g_variant_builder_close (&b); return g_variant_builder_end (&b); } GList * bamf_view_get_parents (BamfView *view) { g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); return view->priv->parents; } static void bamf_view_handle_child_closed (BamfView *child, BamfView *view) { bamf_view_remove_child (view, child); } static void on_child_view_exported (BamfView *child, BamfView *view) { g_signal_emit_by_name (view, "child-added", bamf_view_get_path (child)); g_signal_handlers_disconnect_by_func (child, on_child_view_exported, view); } void bamf_view_add_child (BamfView *view, BamfView *child) { const char * added; g_return_if_fail (BAMF_IS_VIEW (view)); g_return_if_fail (BAMF_IS_VIEW (child)); g_signal_connect (G_OBJECT (child), "closed-internal", G_CALLBACK (bamf_view_handle_child_closed), view); /* Make sure our parent child lists are ok, pay attention to whose list you add parents to */ view->priv->children = g_list_prepend (view->priv->children, child); child->priv->parents = g_list_prepend (child->priv->parents, view); if (bamf_view_is_on_bus (child)) { added = bamf_view_get_path (child); g_signal_emit_by_name (view, "child-added", added); } else { g_signal_connect (G_OBJECT (child), "exported", G_CALLBACK (on_child_view_exported), view); } // Do this by hand so we can pass and object instead of a string if (BAMF_VIEW_GET_CLASS (view)->child_added) BAMF_VIEW_GET_CLASS (view)->child_added (view, child); } void bamf_view_remove_child (BamfView *view, BamfView *child) { const char *removed; g_return_if_fail (BAMF_IS_VIEW (view)); g_return_if_fail (BAMF_IS_VIEW (child)); g_signal_handlers_disconnect_by_data (child, view); /* Make sure our parent child lists are ok, pay attention to whose list you add parents to */ view->priv->children = g_list_remove (view->priv->children, child); child->priv->parents = g_list_remove (child->priv->parents, view); removed = bamf_view_get_path (child); g_signal_emit_by_name (view, "child-removed", removed); /* Do this by hand so we can pass and object instead of a string */ if (BAMF_VIEW_GET_CLASS (view)->child_removed) BAMF_VIEW_GET_CLASS (view)->child_removed (view, child); } #define BAMF_VIEW_GET_PROPERTY(v, property, ret_val) \ g_return_val_if_fail (BAMF_IS_VIEW (v), ret_val); \ \ if (v->priv->props) \ return v->priv->props->property; \ \ return _bamf_dbus_item_view_get_##property (v->priv->dbus_iface); #define BAMF_VIEW_SET_BOOL_PROPERTY(v, property) \ g_return_if_fail (BAMF_IS_VIEW (v)); \ \ if (property == bamf_view_is_##property (v)) \ return; \ \ if (v->priv->props) \ { \ v->priv->props->property = property; \ } \ else \ { \ _bamf_dbus_item_view_set_##property (v->priv->dbus_iface, property); \ } \ \ bamf_view_##property##_changed (v, property); #define BAMF_VIEW_SET_STRING_PROPERTY(v, property) \ g_return_if_fail (BAMF_IS_VIEW (v)); \ \ const gchar *current_value = bamf_view_get_##property (v); \ \ if (current_value == property || g_strcmp0 (current_value, property) == 0) \ return; \ \ bamf_view_##property##_changed (v, property); \ \ if (v->priv->props) \ { \ g_free (v->priv->props->property); \ v->priv->props->property = g_strdup (property); \ } \ else \ { \ _bamf_dbus_item_view_set_##property (v->priv->dbus_iface, property); \ } gboolean bamf_view_is_active (BamfView *view) { BAMF_VIEW_GET_PROPERTY (view, active, FALSE); } void bamf_view_set_active (BamfView *view, gboolean active) { BAMF_VIEW_SET_BOOL_PROPERTY (view, active); } gboolean bamf_view_is_urgent (BamfView *view) { BAMF_VIEW_GET_PROPERTY (view, urgent, FALSE); } void bamf_view_set_urgent (BamfView *view, gboolean urgent) { BAMF_VIEW_SET_BOOL_PROPERTY (view, urgent); } gboolean bamf_view_is_starting (BamfView *view) { BAMF_VIEW_GET_PROPERTY (view, starting, FALSE); } void bamf_view_set_starting (BamfView *view, SnStartupSequence *startup_sequence, gboolean starting) { if (!bamf_view_is_starting (view) && starting) { if (view->priv->startup_sequence) { sn_startup_sequence_unref (view->priv->startup_sequence); view->priv->startup_sequence = NULL; } if (startup_sequence) { view->priv->startup_sequence = startup_sequence; sn_startup_sequence_ref (view->priv->startup_sequence); } } else if (!starting) { if (view->priv->startup_sequence) { sn_startup_sequence_complete (view->priv->startup_sequence); sn_startup_sequence_unref (view->priv->startup_sequence); view->priv->startup_sequence = NULL; } } BAMF_VIEW_SET_BOOL_PROPERTY (view, starting); } gboolean bamf_view_is_running (BamfView *view) { BAMF_VIEW_GET_PROPERTY (view, running, FALSE); } void bamf_view_set_running (BamfView *view, gboolean running) { BAMF_VIEW_SET_BOOL_PROPERTY (view, running); } gboolean bamf_view_is_user_visible (BamfView *view) { BAMF_VIEW_GET_PROPERTY (view, user_visible, FALSE); } void bamf_view_set_user_visible (BamfView *view, gboolean user_visible) { BAMF_VIEW_SET_BOOL_PROPERTY (view, user_visible); } const char * bamf_view_get_icon (BamfView *view) { BAMF_VIEW_GET_PROPERTY (view, icon, NULL); } void bamf_view_set_icon (BamfView *view, const char *icon) { BAMF_VIEW_SET_STRING_PROPERTY (view, icon); } const char * bamf_view_get_name (BamfView *view) { BAMF_VIEW_GET_PROPERTY (view, name, NULL); } void bamf_view_set_name (BamfView *view, const char *name) { BAMF_VIEW_SET_STRING_PROPERTY (view, name); } const char * bamf_view_get_view_type (BamfView *view) { g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); if (BAMF_VIEW_GET_CLASS (view)->view_type) return BAMF_VIEW_GET_CLASS (view)->view_type (view); return "view"; } static char * bamf_view_get_stable_bus_name (BamfView *view) { g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); if (BAMF_VIEW_GET_CLASS (view)->stable_bus_name) return BAMF_VIEW_GET_CLASS (view)->stable_bus_name (view); return g_strdup_printf ("view/%p", view); } static void bamf_view_cached_properties_clear (BamfView *view) { if (!view->priv->props) return; g_free (view->priv->props->name); g_free (view->priv->props->icon); g_free (view->priv->props); view->priv->props = NULL; } static void bamf_view_cached_properties_notify (BamfView *view) { if (!view->priv->props || !bamf_view_is_on_bus (view)) return; /* Temporary disable the cache so that cached values will be set on the skeleton */ BamfViewPropCache *cache = view->priv->props; view->priv->props = NULL; bamf_view_set_name (view, cache->name); bamf_view_set_icon (view, cache->icon); bamf_view_set_active (view, cache->active); bamf_view_set_starting (view, NULL, cache->starting); bamf_view_set_running (view, cache->running); bamf_view_set_user_visible (view, cache->user_visible); bamf_view_set_urgent (view, cache->urgent); view->priv->props = cache; } const char * bamf_view_export_on_bus (BamfView *view, GDBusConnection *connection) { char *path = NULL; GList *ifaces, *l; GError *error = NULL; g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL); if (!view->priv->path) { gboolean exported = TRUE; char *stable_name = bamf_view_get_stable_bus_name (view); path = g_strconcat (BAMF_DBUS_BASE_PATH, "/", stable_name, NULL); g_free (stable_name); BAMF_VIEW_GET_CLASS (view)->names = g_list_prepend (BAMF_VIEW_GET_CLASS (view)->names, path); view->priv->path = path; ifaces = g_dbus_object_get_interfaces (G_DBUS_OBJECT (view)); /* The dbus object interface list is in reversed order, we try to export * the interfaces in bottom to top order (BamfView should be the first) */ for (l = g_list_last (ifaces); l; l = l->prev) { g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (l->data), connection, path, &error); if (error) { g_critical ("Can't register BAMF view interface: %s", error->message); g_clear_error (&error); exported = FALSE; } } if (exported) { /* FIXME: if we change the properties before that the view has been * exported, the skeleton doesn't emit the proper signals to notify * the proxy that the values have been changed, and this causes * the properties not to be updated on the client side. * So we store the values locally until the proxy is not exported, * then we notify our clients. */ bamf_view_cached_properties_notify (view); bamf_view_cached_properties_clear (view); g_signal_emit (view, view_signals[EXPORTED], 0); } g_list_free_full (ifaces, g_object_unref); } return view->priv->path; } gboolean bamf_view_is_on_bus (BamfView *view) { g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); GDBusInterfaceSkeleton *dbus_iface; const gchar *exported_path; if (!view->priv->path) return FALSE; dbus_iface = G_DBUS_INTERFACE_SKELETON (view->priv->dbus_iface); exported_path = g_dbus_interface_skeleton_get_object_path (dbus_iface); return (exported_path != NULL); } static void on_view_active_changed (BamfView *view, gboolean active, gpointer _not_used) { g_return_if_fail (BAMF_IS_VIEW (view)); g_signal_emit_by_name (view->priv->dbus_iface, "active-changed", active); } static void on_view_running_changed (BamfView *view, gboolean running, gpointer _not_used) { g_return_if_fail (BAMF_IS_VIEW (view)); g_signal_emit_by_name (view->priv->dbus_iface, "running-changed", running); } static void on_view_urgent_changed (BamfView *view, gboolean urgent, gpointer _not_used) { g_return_if_fail (BAMF_IS_VIEW (view)); g_signal_emit_by_name (view->priv->dbus_iface, "urgent-changed", urgent); } static void on_view_user_visible_changed (BamfView *view, gboolean user_visible, gpointer _not_used) { g_return_if_fail (BAMF_IS_VIEW (view)); g_signal_emit_by_name (view->priv->dbus_iface, "user-visible-changed", user_visible); } static void on_view_name_changed (BamfView *view, const gchar *old_name, const gchar *new_name, gpointer _not_used) { g_return_if_fail (BAMF_IS_VIEW (view)); g_signal_emit_by_name (view->priv->dbus_iface, "name-changed", old_name ? old_name : "", new_name ? new_name : ""); } static void on_view_child_added (BamfView *view, const gchar *child_path, gpointer _not_used) { g_return_if_fail (BAMF_IS_VIEW (view)); g_signal_emit_by_name (view->priv->dbus_iface, "child-added", child_path ? child_path : ""); } static void on_view_child_removed (BamfView *view, const gchar *child_path, gpointer _not_used) { g_return_if_fail (BAMF_IS_VIEW (view)); g_signal_emit_by_name (view->priv->dbus_iface, "child-removed", child_path ? child_path : ""); } static void on_view_closed (BamfView *view, gpointer _not_used) { g_return_if_fail (BAMF_IS_VIEW (view)); g_dbus_object_skeleton_flush (G_DBUS_OBJECT_SKELETON (view)); g_signal_emit_by_name (view->priv->dbus_iface, "closed"); } static gboolean on_dbus_handle_view_type (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfView *view) { const char *type = bamf_view_get_view_type (view); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", type)); return TRUE; } static gboolean on_dbus_handle_user_visible (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfView *view) { gboolean user_visible = bamf_view_is_user_visible (view); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", user_visible)); return TRUE; } static gboolean on_dbus_handle_icon (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfView *view) { const char *icon = bamf_view_get_icon (view); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", icon ? icon : "")); return TRUE; } static gboolean on_dbus_handle_name (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfView *view) { const char *name = bamf_view_get_name (view); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", name ? name : "")); return TRUE; } static gboolean on_dbus_handle_is_urgent (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfView *view) { gboolean is_urgent = bamf_view_is_urgent (view); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", is_urgent)); return TRUE; } static gboolean on_dbus_handle_is_running (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfView *view) { gboolean is_running = bamf_view_is_running (view); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", is_running)); return TRUE; } static gboolean on_dbus_handle_is_active (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfView *view) { gboolean is_active = bamf_view_is_active (view); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", is_active)); return TRUE; } static gboolean on_dbus_handle_parents (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfView *view) { GVariant *parents = bamf_view_get_parent_paths (view); g_dbus_method_invocation_return_value (invocation, parents); return TRUE; } static gboolean on_dbus_handle_children (BamfDBusItemView *interface, GDBusMethodInvocation *invocation, BamfView *view) { GVariant *children = bamf_view_get_children_paths (view); g_dbus_method_invocation_return_value (invocation, children); return TRUE; } static void bamf_view_dispose (GObject *object) { BamfView *view = BAMF_VIEW (object); BamfViewPrivate *priv = view->priv; if (priv->path) { g_free (priv->path); priv->path = NULL; } if (priv->children) { g_list_free (priv->children); priv->children = NULL; } if (priv->parents) { g_list_free (priv->parents); priv->parents = NULL; } if (priv->starting_timeout) { g_source_remove (priv->starting_timeout); priv->starting_timeout = 0; } if (priv->active_changed_idle) { g_source_remove (priv->active_changed_idle); priv->active_changed_idle = 0; } if (priv->startup_sequence) { sn_startup_sequence_unref (priv->startup_sequence); priv->startup_sequence = NULL; } bamf_view_cached_properties_clear (view); g_dbus_object_skeleton_flush (G_DBUS_OBJECT_SKELETON (view)); G_OBJECT_CLASS (bamf_view_parent_class)->dispose (object); } static void bamf_view_finalize (GObject *object) { BamfView *view = BAMF_VIEW (object); g_object_unref (view->priv->dbus_iface); G_OBJECT_CLASS (bamf_view_parent_class)->finalize (object); } static void bamf_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { BamfView *view = BAMF_VIEW (object); switch (property_id) { case PROP_NAME: g_value_set_string (value, bamf_view_get_name (view)); break; case PROP_ICON: g_value_set_string (value, bamf_view_get_icon (view)); break; case PROP_ACTIVE: g_value_set_boolean (value, bamf_view_is_active (view)); break; case PROP_URGENT: g_value_set_boolean (value, bamf_view_is_urgent (view)); break; case PROP_USER_VISIBLE: g_value_set_boolean (value, bamf_view_is_user_visible (view)); break; case PROP_STARTING: g_value_set_boolean (value, bamf_view_is_starting (view)); break; case PROP_RUNNING: g_value_set_boolean (value, bamf_view_is_running (view)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } } static void bamf_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { switch (property_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void bamf_view_init (BamfView * self) { self->priv = bamf_view_get_instance_private (self); /* Initializing the dbus interface */ self->priv->dbus_iface = _bamf_dbus_item_view_skeleton_new (); self->priv->props = g_new0 (BamfViewPropCache, 1); self->priv->startup_sequence = NULL; /* We need to connect to the object own signals to redirect them to the dbus * interface */ g_signal_connect (self, "active-changed", G_CALLBACK (on_view_active_changed), NULL); g_signal_connect (self, "running-changed", G_CALLBACK (on_view_running_changed), NULL); g_signal_connect (self, "urgent-changed", G_CALLBACK (on_view_urgent_changed), NULL); g_signal_connect (self, "user-visible-changed", G_CALLBACK (on_view_user_visible_changed), NULL); g_signal_connect (self, "name-changed", G_CALLBACK (on_view_name_changed), NULL); g_signal_connect (self, "child-added", G_CALLBACK (on_view_child_added), NULL); g_signal_connect (self, "child-removed", G_CALLBACK (on_view_child_removed), NULL); g_signal_connect (self, "closed", G_CALLBACK (on_view_closed), NULL); /* Registering signal callbacks to reply to dbus method calls */ g_signal_connect (self->priv->dbus_iface, "handle-view-type", G_CALLBACK (on_dbus_handle_view_type), self); g_signal_connect (self->priv->dbus_iface, "handle-user-visible", G_CALLBACK (on_dbus_handle_user_visible), self); g_signal_connect (self->priv->dbus_iface, "handle-icon", G_CALLBACK (on_dbus_handle_icon), self); g_signal_connect (self->priv->dbus_iface, "handle-name", G_CALLBACK (on_dbus_handle_name), self); g_signal_connect (self->priv->dbus_iface, "handle-is-urgent", G_CALLBACK (on_dbus_handle_is_urgent), self); g_signal_connect (self->priv->dbus_iface, "handle-is-running", G_CALLBACK (on_dbus_handle_is_running), self); g_signal_connect (self->priv->dbus_iface, "handle-is-active", G_CALLBACK (on_dbus_handle_is_active), self); g_signal_connect (self->priv->dbus_iface, "handle-parents", G_CALLBACK (on_dbus_handle_parents), self); g_signal_connect (self->priv->dbus_iface, "handle-children", G_CALLBACK (on_dbus_handle_children), self); /* Setting the interface for the dbus object */ _bamf_dbus_item_object_skeleton_set_view (BAMF_DBUS_ITEM_OBJECT_SKELETON (self), self->priv->dbus_iface); } static void bamf_view_dbus_view_iface_init (BamfDBusItemViewIface *iface) { } static void bamf_view_class_init (BamfViewClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = bamf_view_dispose; object_class->finalize = bamf_view_finalize; object_class->get_property = bamf_view_get_property; object_class->set_property = bamf_view_set_property; /* Overriding the properties defined in the interface, this is needed * but we actually don't use these properties, as we act like a proxy */ g_object_class_override_property (object_class, PROP_NAME, "name"); g_object_class_override_property (object_class, PROP_ICON, "icon"); g_object_class_override_property (object_class, PROP_ACTIVE, "active"); g_object_class_override_property (object_class, PROP_URGENT, "urgent"); g_object_class_override_property (object_class, PROP_STARTING, "starting"); g_object_class_override_property (object_class, PROP_RUNNING, "running"); g_object_class_override_property (object_class, PROP_USER_VISIBLE, "user-visible"); view_signals [CLOSED_INTERNAL] = g_signal_new ("closed-internal", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (BamfViewClass, closed_internal), NULL, NULL, NULL, G_TYPE_NONE, 0); view_signals [EXPORTED] = g_signal_new ("exported", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfViewClass, exported), NULL, NULL, NULL, G_TYPE_NONE, 0); } ./src/Makefile.am0000644000004100000410000000275314203512426014074 0ustar www-datawww-dataLIBBAMF_PRIVATE_LIB = $(top_builddir)/lib/libbamf-private/libbamf-private.la bamfdaemondir = $(pkglibexecdir) bamfdaemon_PROGRAMS = \ bamfdaemon \ $(NULL) bamfdaemon_sources = \ main.c \ bamf-daemon.c \ bamf-legacy-window.c \ bamf-legacy-window-test.c \ bamf-legacy-screen.c \ bamf-view.c \ bamf-control.c \ bamf-matcher.c \ bamf-application.c \ bamf-window.c \ bamf-tab.c \ bamf-xutils.c \ $(NULL) bamfdaemon_headers = \ main.h \ bamf-daemon.h \ bamf-legacy-window.h \ bamf-legacy-window-test.h \ bamf-legacy-screen.h \ bamf-legacy-screen-private.h \ bamf-view.h \ bamf-control.h \ bamf-matcher.h \ bamf-matcher-private.h \ bamf-window.h \ bamf-application.h \ bamf-tab.h \ bamf-xutils.h \ $(NULL) bamfdaemon_SOURCES = \ $(bamfdaemon_sources) \ $(bamfdaemon_headers) \ $(NULL) bamfdaemon_LDADD = \ $(LIBBAMF_PRIVATE_LIB) \ $(X_LIBS) \ $(GLIB_LIBS) \ $(GTK_LIBS) \ $(SN_LIBS) \ $(WNCK_LIBS) \ $(GTOP_LIBS) \ $(NULL) bamfdaemon_CFLAGS = \ -Wall -std=c99 \ -DDATADIR=\""$(datadir)"\" \ -DWNCK_I_KNOW_THIS_IS_UNSTABLE \ -I$(srcdir) \ -I$(top_srcdir)/lib \ -I$(top_builddir)/lib \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(SN_CFLAGS) \ $(WNCK_CFLAGS) \ $(GTOP_CFLAGS) \ $(COVERAGE_CFLAGS) \ $(NULL) if EXPORT_ACTIONS_MENU bamfdaemon_LDADD += $(DBUSMENU_LIBS) bamfdaemon_CFLAGS += $(DBUSMENU_CFLAGS) bamfdaemon_CFLAGS += -DEXPORT_ACTIONS_MENU endif bamfdaemon_LDFLAGS = \ -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions \ $(COVERAGE_LDFLAGS) \ $(NULL) ./src/bamf-window.c0000644000004100000410000005004314203512426014411 0ustar www-datawww-data/* * Copyright (C) 2010 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * */ #include "bamf-application.h" #include "bamf-window.h" #include "bamf-legacy-screen.h" #include #include #ifdef EXPORT_ACTIONS_MENU #include #include #include #endif #define _GTK_APPLICATION_ID "_GTK_APPLICATION_ID" #define SNAP_SECURITY_LABEL_PREFIX "snap." static void bamf_window_dbus_iface_init (BamfDBusItemWindowIface *iface); static GList *bamf_windows = NULL; enum { PROP_0, PROP_WINDOW, }; struct _BamfWindowPrivate { BamfDBusItemWindow *dbus_iface; BamfLegacyWindow *legacy_window; BamfWindowMaximizationType maximized; gint monitor; #ifdef EXPORT_ACTIONS_MENU DbusmenuServer *dbusmenu_server; GtkWidget *action_menu; gboolean was_active; #endif }; G_DEFINE_TYPE_WITH_CODE (BamfWindow, bamf_window, BAMF_TYPE_VIEW, G_ADD_PRIVATE(BamfWindow) G_IMPLEMENT_INTERFACE (BAMF_DBUS_ITEM_TYPE_WINDOW, bamf_window_dbus_iface_init)); BamfLegacyWindow * bamf_window_get_window (BamfWindow *self) { g_return_val_if_fail (BAMF_IS_WINDOW (self), NULL); if (BAMF_WINDOW_GET_CLASS (self)->get_window) return BAMF_WINDOW_GET_CLASS (self)->get_window (self); return self->priv->legacy_window; } BamfWindow * bamf_window_get_transient (BamfWindow *self) { BamfLegacyWindow *legacy, *transient; BamfWindow *other; GList *l; g_return_val_if_fail (BAMF_IS_WINDOW (self), NULL); legacy = bamf_window_get_window (self); transient = bamf_legacy_window_get_transient (legacy); if (transient) { for (l = bamf_windows; l; l = l->next) { other = l->data; if (!BAMF_IS_WINDOW (other)) continue; if (transient == bamf_window_get_window (other)) return other; } } return NULL; } const char * bamf_window_get_transient_path (BamfWindow *self) { BamfWindow *transient; g_return_val_if_fail (BAMF_IS_WINDOW (self), NULL); transient = bamf_window_get_transient (self); if (transient == NULL) return ""; return bamf_view_get_path (BAMF_VIEW (transient)); } guint32 bamf_window_get_window_type (BamfWindow *window) { g_return_val_if_fail (BAMF_IS_WINDOW (window), 0); return (guint32) bamf_legacy_window_get_window_type (window->priv->legacy_window); } guint32 bamf_window_get_pid (BamfWindow *window) { g_return_val_if_fail (BAMF_IS_WINDOW (window), 0); return bamf_legacy_window_get_pid (window->priv->legacy_window); } guint32 bamf_window_get_xid (BamfWindow *window) { g_return_val_if_fail (BAMF_IS_WINDOW (window), 0); if (BAMF_WINDOW_GET_CLASS (window)->get_xid) return BAMF_WINDOW_GET_CLASS (window)->get_xid (window); return (guint32) bamf_legacy_window_get_xid (window->priv->legacy_window); } static void handle_window_closed (BamfLegacyWindow * window, gpointer data) { BamfWindow *self; self = (BamfWindow *) data; g_return_if_fail (BAMF_IS_WINDOW (self)); g_return_if_fail (BAMF_IS_LEGACY_WINDOW (window)); if (window == self->priv->legacy_window) { bamf_view_close (BAMF_VIEW (self)); } } static void handle_name_changed (BamfLegacyWindow *window, BamfWindow *self) { g_return_if_fail (BAMF_IS_LEGACY_WINDOW (window)); bamf_view_set_name (BAMF_VIEW (self), bamf_legacy_window_get_name (window)); } static void bamf_window_ensure_flags (BamfWindow *self) { g_return_if_fail (BAMF_IS_WINDOW (self)); #ifdef EXPORT_ACTIONS_MENU self->priv->was_active = bamf_view_is_active (BAMF_VIEW (self)); #endif bamf_view_set_active (BAMF_VIEW (self), bamf_legacy_window_is_active (self->priv->legacy_window)); bamf_view_set_urgent (BAMF_VIEW (self), bamf_legacy_window_needs_attention (self->priv->legacy_window)); bamf_view_set_user_visible (BAMF_VIEW (self), !bamf_legacy_window_is_skip_tasklist (self->priv->legacy_window)); BamfWindowMaximizationType maximized = bamf_window_maximized (self); if (self->priv->maximized != maximized) { BamfWindowMaximizationType old_state = self->priv->maximized; self->priv->maximized = maximized; g_signal_emit_by_name (self, "maximized-changed", old_state, maximized); } #ifdef EXPORT_ACTIONS_MENU if (self->priv->dbusmenu_server && !self->priv->was_active && !bamf_view_is_active (BAMF_VIEW (self))) { g_clear_object (&self->priv->dbusmenu_server); g_clear_object (&self->priv->action_menu); } #endif } static void bamf_window_ensure_monitor (BamfWindow *self) { g_return_if_fail (BAMF_IS_WINDOW (self)); gint monitor = bamf_window_get_monitor (self); if (self->priv->monitor != monitor) { gint old_monitor = self->priv->monitor; self->priv->monitor = monitor; g_signal_emit_by_name (self, "monitor-changed", old_monitor, monitor); } } static void handle_state_changed (BamfLegacyWindow *window, BamfWindow *self) { bamf_window_ensure_flags (self); } static void handle_geometry_changed (BamfLegacyWindow *window, BamfWindow *self) { bamf_window_ensure_monitor (self); } static const char * bamf_window_get_view_type (BamfView *view) { return "window"; } char * bamf_window_get_string_hint (BamfWindow *self, const char* prop) { g_return_val_if_fail (BAMF_IS_WINDOW (self), NULL); return bamf_legacy_window_get_hint (self->priv->legacy_window, prop); } static char * get_snap_desktop_id (guint pid) { char *security_label_filename = NULL; char *security_label_contents = NULL; gsize i, security_label_contents_size = 0; char *contents_start; char *contents_end; char *sandboxed_app_id; g_return_val_if_fail (pid != 0, NULL); security_label_filename = g_strdup_printf ("/proc/%u/attr/current", pid); if (!g_file_get_contents (security_label_filename, &security_label_contents, &security_label_contents_size, NULL)) { g_free (security_label_filename); return NULL; } if (!g_str_has_prefix (security_label_contents, SNAP_SECURITY_LABEL_PREFIX)) { g_free (security_label_filename); g_free (security_label_contents); return NULL; } /* We need to translate the security profile into the desktop-id. * The profile is in the form of 'snap.name-space.binary-name (current)' * while the desktop id will be name-space_binary-name. */ security_label_contents_size -= sizeof (SNAP_SECURITY_LABEL_PREFIX) - 1; contents_start = security_label_contents + sizeof (SNAP_SECURITY_LABEL_PREFIX) - 1; contents_end = strchr (contents_start, ' '); if (contents_end) security_label_contents_size = contents_end - contents_start; for (i = 0; i < security_label_contents_size; ++i) { if (contents_start[i] == '.') contents_start[i] = '_'; } sandboxed_app_id = g_malloc0 (security_label_contents_size + 1); memcpy (sandboxed_app_id, contents_start, security_label_contents_size); g_free (security_label_filename); g_free (security_label_contents); return sandboxed_app_id; } static char * get_flatpak_desktop_id (guint pid) { GKeyFile *key_file = NULL; char *info_filename = NULL; char *app_id = NULL; g_return_val_if_fail (pid != 0, NULL); key_file = g_key_file_new (); info_filename = g_strdup_printf ("/proc/%u/root/.flatpak-info", pid); if (!g_key_file_load_from_file (key_file, info_filename, G_KEY_FILE_NONE, NULL)) { g_free (info_filename); return NULL; } app_id = g_key_file_get_string (key_file, "Application", "name", NULL); g_key_file_free (key_file); g_free (info_filename); return app_id; } char * bamf_window_get_application_id (BamfWindow *self) { guint pid; char *app_id; g_return_val_if_fail (BAMF_IS_WINDOW (self), NULL); pid = bamf_window_get_pid (self); if (pid > 0) { app_id = get_snap_desktop_id (pid); if (app_id) return app_id; app_id = get_flatpak_desktop_id (pid); if (app_id) return app_id; } app_id = bamf_window_get_string_hint (self, _GTK_APPLICATION_ID); return app_id; } BamfWindowMaximizationType bamf_window_maximized (BamfWindow *self) { g_return_val_if_fail (BAMF_IS_WINDOW (self), BAMF_WINDOW_FLOATING); return bamf_legacy_window_maximized (self->priv->legacy_window); } gint bamf_window_get_monitor (BamfWindow *self) { gint x, y, width, height; g_return_val_if_fail (BAMF_IS_WINDOW (self), -1); GdkScreen *gdk_screen = gdk_screen_get_default (); bamf_legacy_window_get_geometry (self->priv->legacy_window, &x, &y, &width, &height); return gdk_screen_get_monitor_at_point (gdk_screen, x + width/2, y + height/2); } static char * bamf_window_get_stable_bus_name (BamfView *view) { BamfWindow *self; g_return_val_if_fail (BAMF_IS_WINDOW (view), NULL); self = BAMF_WINDOW (view); return g_strdup_printf ("window/%u", bamf_legacy_window_get_xid (self->priv->legacy_window)); } gint bamf_window_get_stack_position (BamfWindow *self) { g_return_val_if_fail (BAMF_IS_WINDOW (self), -1); return bamf_legacy_window_get_stacking_position (self->priv->legacy_window); } static void active_window_changed (BamfLegacyScreen *screen, BamfWindow *window) { bamf_window_ensure_flags (window); } #ifdef EXPORT_ACTIONS_MENU static gboolean bamf_window_active_changed (BamfView *view, gboolean active) { BamfWindow *self = BAMF_WINDOW (view); BamfWindowPrivate *priv = self->priv; GtkWidget *window_menu; BamfWindowType win_type; const char *view_path; if (!active && !priv->was_active) { g_clear_object (&priv->dbusmenu_server); g_clear_object (&priv->action_menu); return FALSE; } if (priv->dbusmenu_server) return FALSE; win_type = bamf_window_get_window_type (self); if (win_type == BAMF_WINDOW_DOCK || win_type == BAMF_WINDOW_TOOLBAR || win_type == BAMF_WINDOW_MENU || win_type == BAMF_WINDOW_SPLASHSCREEN) { return FALSE; } window_menu = bamf_legacy_window_get_action_menu (priv->legacy_window); if (!GTK_IS_WIDGET (window_menu)) return FALSE; view_path = bamf_view_get_path (view); priv->dbusmenu_server = dbusmenu_server_new (view_path); priv->action_menu = gtk_menu_new (); g_object_ref_sink (priv->action_menu); GtkWidget *menuitem = gtk_menu_item_new_with_label (_("Window actions")); gtk_widget_show (menuitem); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), window_menu); gtk_menu_shell_append (GTK_MENU_SHELL (priv->action_menu), menuitem); dbusmenu_server_set_root (priv->dbusmenu_server, dbusmenu_gtk_parse_menu_structure (priv->action_menu)); return FALSE; } #endif static gboolean on_dbus_handle_get_pid (BamfDBusItemWindow *interface, GDBusMethodInvocation *invocation, BamfWindow *self) { gint pid = bamf_window_get_pid (self); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", pid)); return TRUE; } static gboolean on_dbus_handle_get_xid (BamfDBusItemWindow *interface, GDBusMethodInvocation *invocation, BamfWindow *self) { guint32 xid = bamf_window_get_xid (self); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", xid)); return TRUE; } static gboolean on_dbus_handle_transient (BamfDBusItemWindow *interface, GDBusMethodInvocation *invocation, BamfWindow *self) { const char *transient_path = bamf_window_get_transient_path (self); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", transient_path)); return TRUE; } static gboolean on_dbus_handle_window_type (BamfDBusItemWindow *interface, GDBusMethodInvocation *invocation, BamfWindow *self) { BamfWindowType window_type = bamf_window_get_window_type (self); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", window_type)); return TRUE; } static gboolean on_dbus_handle_xprop (BamfDBusItemWindow *interface, GDBusMethodInvocation *invocation, const gchar *prop, BamfWindow *self) { char *hint = bamf_window_get_string_hint (self, prop); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", hint ? hint : "")); g_free (hint); return TRUE; } static gboolean on_dbus_handle_monitor (BamfDBusItemWindow *interface, GDBusMethodInvocation *invocation, BamfWindow *self) { gint monitor = bamf_window_get_monitor (self); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(i)", monitor)); return TRUE; } static gboolean on_dbus_handle_maximized (BamfDBusItemWindow *interface, GDBusMethodInvocation *invocation, BamfWindow *self) { BamfWindowMaximizationType maximized = bamf_window_maximized (self); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(i)", maximized)); return TRUE; } static void bamf_window_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { BamfWindow *self; self = BAMF_WINDOW (object); switch (property_id) { case PROP_WINDOW: self->priv->legacy_window = BAMF_LEGACY_WINDOW (g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } } static void bamf_window_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { BamfWindow *self; self = BAMF_WINDOW (object); switch (property_id) { case PROP_WINDOW: g_value_set_object (value, self->priv->legacy_window); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } } static void on_maximized_changed (BamfWindow *self, BamfWindowMaximizationType old, BamfWindowMaximizationType new, gpointer _not_used) { g_return_if_fail (BAMF_IS_WINDOW (self)); g_signal_emit_by_name (self->priv->dbus_iface, "maximized-changed", old, new); } static void on_monitor_changed (BamfWindow *self, gint old, gint new, gpointer _not_used) { g_return_if_fail (BAMF_IS_WINDOW (self)); g_signal_emit_by_name (self->priv->dbus_iface, "monitor-changed", old, new); } static void bamf_window_constructed (GObject *object) { BamfWindow *self; BamfLegacyWindow *window; if (G_OBJECT_CLASS (bamf_window_parent_class)->constructed) G_OBJECT_CLASS (bamf_window_parent_class)->constructed (object); g_object_get (object, "legacy-window", &window, NULL); self = BAMF_WINDOW (object); bamf_windows = g_list_prepend (bamf_windows, self); bamf_view_set_name (BAMF_VIEW (self), bamf_legacy_window_get_name (window)); g_signal_connect (G_OBJECT (window), "name-changed", (GCallback) handle_name_changed, self); g_signal_connect (G_OBJECT (window), "state-changed", (GCallback) handle_state_changed, self); g_signal_connect (G_OBJECT (window), "geometry-changed", (GCallback) handle_geometry_changed, self); g_signal_connect (G_OBJECT (window), "closed", (GCallback) handle_window_closed, self); self->priv->maximized = -1; self->priv->monitor = -1; bamf_window_ensure_flags (self); bamf_window_ensure_monitor (self); } static void bamf_window_dispose (GObject *object) { BamfWindow *self; self = BAMF_WINDOW (object); bamf_windows = g_list_remove (bamf_windows, self); g_signal_handlers_disconnect_by_func (bamf_legacy_screen_get_default (), active_window_changed, self); if (self->priv->legacy_window) { g_signal_handlers_disconnect_by_data (self->priv->legacy_window, self); g_object_unref (self->priv->legacy_window); self->priv->legacy_window = NULL; } #ifdef EXPORT_ACTIONS_MENU g_clear_object (&self->priv->dbusmenu_server); g_clear_object (&self->priv->action_menu); #endif G_OBJECT_CLASS (bamf_window_parent_class)->dispose (object); } static void bamf_window_finalize (GObject *object) { BamfWindow *self; self = BAMF_WINDOW (object); g_object_unref (self->priv->dbus_iface); G_OBJECT_CLASS (bamf_window_parent_class)->finalize (object); } static void bamf_window_init (BamfWindow * self) { self->priv = bamf_window_get_instance_private (self); /* Initializing the dbus interface */ self->priv->dbus_iface = _bamf_dbus_item_window_skeleton_new (); /* We need to connect to the object own signals to redirect them to the dbus * interface */ g_signal_connect (self, "maximized-changed", G_CALLBACK (on_maximized_changed), NULL); g_signal_connect (self, "monitor-changed", G_CALLBACK (on_monitor_changed), NULL); /* Registering signal callbacks to reply to dbus method calls */ g_signal_connect (self->priv->dbus_iface, "handle-get-pid", G_CALLBACK (on_dbus_handle_get_pid), self); g_signal_connect (self->priv->dbus_iface, "handle-get-xid", G_CALLBACK (on_dbus_handle_get_xid), self); g_signal_connect (self->priv->dbus_iface, "handle-transient", G_CALLBACK (on_dbus_handle_transient), self); g_signal_connect (self->priv->dbus_iface, "handle-window-type", G_CALLBACK (on_dbus_handle_window_type), self); g_signal_connect (self->priv->dbus_iface, "handle-xprop", G_CALLBACK (on_dbus_handle_xprop), self); g_signal_connect (self->priv->dbus_iface, "handle-monitor", G_CALLBACK (on_dbus_handle_monitor), self); g_signal_connect (self->priv->dbus_iface, "handle-maximized", G_CALLBACK (on_dbus_handle_maximized), self); /* Setting the interface for the dbus object */ _bamf_dbus_item_object_skeleton_set_window (BAMF_DBUS_ITEM_OBJECT_SKELETON (self), self->priv->dbus_iface); g_signal_connect (G_OBJECT (bamf_legacy_screen_get_default ()), "active-window-changed", (GCallback) active_window_changed, self); } static void bamf_window_dbus_iface_init (BamfDBusItemWindowIface *iface) { } static void bamf_window_class_init (BamfWindowClass * klass) { GParamSpec *pspec; GObjectClass *object_class = G_OBJECT_CLASS (klass); BamfViewClass *view_class = BAMF_VIEW_CLASS (klass); object_class->dispose = bamf_window_dispose; object_class->finalize = bamf_window_finalize; object_class->get_property = bamf_window_get_property; object_class->set_property = bamf_window_set_property; object_class->constructed = bamf_window_constructed; view_class->view_type = bamf_window_get_view_type; view_class->stable_bus_name = bamf_window_get_stable_bus_name; #ifdef EXPORT_ACTIONS_MENU view_class->active_changed = bamf_window_active_changed; #endif pspec = g_param_spec_object ("legacy-window", "legacy-window", "legacy-window", BAMF_TYPE_LEGACY_WINDOW, G_PARAM_READWRITE | G_PARAM_CONSTRUCT); g_object_class_install_property (object_class, PROP_WINDOW, pspec); } BamfWindow * bamf_window_new (BamfLegacyWindow *window) { BamfWindow *self; self = (BamfWindow *) g_object_new (BAMF_TYPE_WINDOW, "legacy-window", window, NULL); return self; } ./src/main.h0000644000004100000410000000163514203512426013133 0ustar www-datawww-data/* * Copyright (C) 2010-2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef __MAIN_H__ #define __MAIN_H__ #include #include #include #include #include #include #endif ./src/bamf-legacy-window-test.h0000644000004100000410000001140714203512426016636 0ustar www-datawww-data/* * Copyright (C) 2010 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * */ #ifndef __BAMFMOCKWINDOW_H__ #define __BAMFMOCKWINDOW_H__ #include #include #include #include "bamf-application.h" #include "bamf-window.h" #include "bamf-legacy-window.h" #define BAMF_TYPE_LEGACY_WINDOW_TEST (bamf_legacy_window_test_get_type ()) #define BAMF_LEGACY_WINDOW_TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\ BAMF_TYPE_LEGACY_WINDOW_TEST, BamfLegacyWindowTest)) #define BAMF_LEGACY_WINDOW_TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\ BAMF_TYPE_LEGACY_WINDOW_TEST, BamfLegacyWindowTestClass)) #define BAMF_IS_LEGACY_WINDOW_TEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ BAMF_TYPE_LEGACY_WINDOW_TEST)) #define BAMF_IS_LEGACY_WINDOW_TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ BAMF_TYPE_LEGACY_WINDOW_TEST)) #define BAMF_LEGACY_WINDOW_TEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ BAMF_TYPE_LEGACY_WINDOW_TEST, BamfLegacyWindowTestClass)) typedef struct _BamfLegacyWindowTest BamfLegacyWindowTest; typedef struct _BamfLegacyWindowTestClass BamfLegacyWindowTestClass; struct _BamfLegacyWindowTest { BamfLegacyWindow parent; guint32 xid; guint pid; char * name; char * icon; char * role; char * wm_class_name; char * wm_class_instance; char * exec; char * working_dir; char * process_name; char * application_id; char * unique_bus_name; char * dbus_menu_object_path; BamfLegacyWindow * transient_window; gboolean needs_attention; gboolean is_desktop; gboolean is_skip; gboolean is_active; gboolean is_closed; GdkRectangle geometry; BamfWindowMaximizationType maximized; BamfWindowType window_type; GHashTable * hints; }; struct _BamfLegacyWindowTestClass { /*< private >*/ BamfLegacyWindowClass parent_class; void (*_test_padding1) (void); void (*_test_padding2) (void); void (*_test_padding3) (void); void (*_test_padding4) (void); void (*_test_padding5) (void); void (*_test_padding6) (void); }; GType bamf_legacy_window_test_get_type (void) G_GNUC_CONST; guint bamf_legacy_window_test_get_pid (BamfLegacyWindow *legacy_window); guint32 bamf_legacy_window_test_get_xid (BamfLegacyWindow *legacy_window); void bamf_legacy_window_test_set_attention (BamfLegacyWindowTest *self, gboolean val); gboolean bamf_legacy_window_test_needs_attention (BamfLegacyWindow *legacy_window); void bamf_legacy_window_test_set_active (BamfLegacyWindowTest *self, gboolean val); gboolean bamf_legacy_window_test_is_active (BamfLegacyWindow *legacy_window); void bamf_legacy_window_test_set_desktop (BamfLegacyWindowTest *self, gboolean val); gboolean bamf_legacy_window_test_is_desktop (BamfLegacyWindow *legacy_window); void bamf_legacy_window_test_set_skip (BamfLegacyWindowTest *self, gboolean val); gboolean bamf_legacy_window_test_is_skip_tasklist (BamfLegacyWindow *legacy_window); void bamf_legacy_window_test_set_name (BamfLegacyWindowTest *self, const char *val); void bamf_legacy_window_test_set_icon (BamfLegacyWindowTest *self, const char *val); void bamf_legacy_window_test_set_role (BamfLegacyWindowTest *self, const char *val); void bamf_legacy_window_test_set_geometry (BamfLegacyWindowTest *self, int x, int y, int width, int height); void bamf_legacy_window_test_set_maximized (BamfLegacyWindowTest *self, BamfWindowMaximizationType maximized); void bamf_legacy_window_test_set_application_id (BamfLegacyWindowTest *self, const char *id); void bamf_legacy_window_test_set_unique_bus_name (BamfLegacyWindowTest *self, const char *bus_name); void bamf_legacy_window_test_set_dbus_menu_object_path (BamfLegacyWindowTest *self, const char *object_path); void bamf_legacy_window_test_set_wmclass (BamfLegacyWindowTest *self, const char *class_name, const char *instance_name); void bamf_legacy_window_test_close (BamfLegacyWindowTest *self); BamfLegacyWindowTest * bamf_legacy_window_test_new (guint32 xid, const gchar *name, const gchar *wmclass_name, const gchar *exec); BamfLegacyWindowTest * bamf_legacy_window_copy (BamfLegacyWindowTest *self); #endif ./COPYING.LGPL-2.10000644000004100000410000006362614203512426013345 0ustar www-datawww-data GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! ./libgnome-desktop.patch0000644000004100000410000000126414203512426015531 0ustar www-datawww-data*** a/libgnome-desktop/gnome-desktop-item.c 2009-04-13 18:00:20.000000000 -0400 --- b/libgnome-desktop/gnome-desktop-item.c 2009-07-27 21:26:03.845330578 -0400 *************** *** 58,63 **** --- 58,64 ---- #undef GNOME_DISABLE_DEPRECATED #include #include + #include #include "private.h" *************** *** 2103,2108 **** --- 2122,2132 ---- (flags & GNOME_DESKTOP_ITEM_LAUNCH_DO_NOT_REAP_CHILD), error); + gchar *file = g_filename_from_uri (item->location, NULL, NULL); + bamf_register_desktop_file_for_pid (file, ret); + + g_free (file); + return ret; } ./autogen.sh0000755000004100000410000000112414203512426013241 0ustar www-datawww-data#!/bin/sh # Run this to generate all the initial makefiles, etc. srcdir=`dirname $0` test -z "$srcdir" && srcdir=. REQUIRED_AUTOCONF_VERSION=2.59 REQUIRED_AUTOMAKE_VERSION=1.8 REQUIRED_MACROS="python.m4" ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I m4" (test -f $srcdir/configure.ac) || { echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" echo " top-level $PKG_NAME directory" exit 1 } which gnome-autogen.sh || { echo "You need to install the gnome-common module and make" echo "sure the gnome-autogen.sh script is in your \$PATH." exit 1 } . gnome-autogen.sh ./ChangeLog0000644000004100000410000102773214203512426013030 0ustar www-datawww-data2018-11-07 Marco Trevisan (Treviño) New upstream release: 0.5.4 debian/control: Bump Standards-Version: to 4.1.5. No changes needed 2018-11-07 Mike Gabriel debian/control: Drop B-D on dbus-x11, rather versioned build-depend on dbus (>= 1.8). Stop using dbus-launch during unit tests (use dbus-run-session instead). Fix FTCBFS: lintian tag autotools-pkg-config-macro-not-cross-compilation-safe. 2018-11-07 Marco Trevisan (Treviño) Move .bzrignore to .gitignore and update it autogen.sh: removing deprecated variables 2018-08-29 Marco Trevisan (Treviño) debian/changelog: mention latest packaging changes debian/gbp.conf: add default settings 2018-06-25 Marco Trevisan (Treviño) debian/control: update default vcs 2018-02-07 Bileto Bot Releasing 0.5.3+18.04.20180207.2-0ubuntu1 (bzr r657) 2018-02-07 Marco Trevisan (Treviño) bamf-window: read snap and flatpak IDs and use it to guess desktop-id (LP: #1747802) Approved by: Andrea Azzarone (bzr r656) 2018-02-07 Marco Trevisan (Treviño) bamf-window: free label filename and content on errors Thanks Andrea! (bzr r655.1.6) 2018-02-07 Marco Trevisan (Treviño) BamfWindow: don't try to fetch desktop id from sandboxed apps if we don't know the PID (bzr r655.1.5) 2018-02-06 Marco Trevisan (Treviño) bamf-matcher: remove uneeded extra line (bzr r655.1.4) bamf-window: get app id for flatpak's from their root info (bzr r655.1.3) 2018-02-06 Marco Trevisan (Treviño) bamf-window: read snap security label and use it to guess desktop-id Fixes LP: #1747802 (bzr r655.1.2) 2018-02-06 Marco Trevisan (Treviño) bamf-window: move GTK app id retrieval to bamf_window_get_application_id (bzr r655.1.1) 2017-08-09 Bileto Bot Releasing 0.5.3+17.10.20170810-0ubuntu1 (bzr r655) No-change rebuild against latest libgtop2 (bzr r654) 2017-04-06 Bileto Bot Releasing 0.5.3+17.04.20170406-0ubuntu1 (bzr r653) 2017-04-06 Łukasz 'sil2100' Zemczak As agreed with upstream, do not error out on deprecated declarations. (LP: #1680104) (bzr r652) Add the gnome-common build-dependency to satisfy the gnome-autogen.sh requirement. (LP: #1680104) (bzr r651) As agreed with upstream, do not error out on deprecated declarations. (bzr r650.2.1) 2017-04-05 Łukasz 'sil2100' Zemczak Add the gnome-common build-dependency to satisfy the gnome-autogen.sh requirement. (bzr r650.1.1) 2016-09-29 Bileto Bot Releasing 0.5.3+16.10.20160929-0ubuntu1 (bzr r650) 2016-09-29 Iain Lane Adjust for XDG_CURRENT_DESKTOP containing multiple colon-separated values Approved by: Marco Trevisan (Treviño) (bzr r649) 2016-09-29 Iain Lane Don't leak current_desktops (bzr r648.1.2) 2016-09-29 Iain Lane Account for XDG_CURRENT_DESKTOP containing multiple values We need to split on ":" and compare each part. (bzr r648.1.1) 2016-08-25 Marco Trevisan (Treviño) configure.ac: development version bump to 0.5.4 (bzr r648) 2016-08-25 Marco Trevisan (Treviño) Releasing Bamf 0.5.3 0.5.2 has been skipped (bzr r647) 2016-08-25 Marco Trevisan (Treviño) data/Makefile.am: add bamfdaemon.service(.in) to extra dist and clean files (bzr r646) 2016-07-26 Bileto Bot Releasing 0.5.3~bzr0+16.10.20160726.1-0ubuntu1 2016-07-26 Andrea Azzarone Unscale x/y coordinates returned by top_window_action_menu. (LP: #1606234) Approved by: Marco Trevisan (Treviño) 2016-07-25 Andrea Azzarone Unscale x/y coordinates returned by top_window_action_menu. 2016-07-26 Martin Pitt Add support for starting bamf through user systemd units Approved by: Marco Trevisan (Treviño) 2016-07-18 Martin Pitt Add session systemd service Add bamfdaemon.service similar to the bamfdaemon.conf upstart user job. This will be pulled in via unity7.service Requires= and D-Bus activation, thus don't statically enable the unit. Adjust the D-Bus activation wrapper accordingly. 2016-07-05 Bileto Bot Releasing 0.5.3~bzr0+16.10.20160705-0ubuntu1 2016-07-05 Marco Trevisan (Treviño) debian/bamfdaemon.triggers: use interest-noawait (LP: #1589097) 2016-06-30 Marco Trevisan (Treviño) debian/bamfdaemon.triggers: use interest-noawait 2016-06-28 Bileto Bot Releasing 0.5.3~bzr0+16.10.20160628-0ubuntu1 2016-06-28 Andrea Azzarone Daemon: manually set to complete the startup notification on view state change Specifically when the view is running, activated or marked as urgent. (LP: #1582430) 2016-06-14 Andrea Azzarone Manually set to complete the statup notification if the view is running, activated or marked as urgent. 2016-06-02 Bileto Bot Releasing 0.5.3~bzr0+16.10.20160602-0ubuntu1 2016-06-02 Marco Trevisan (Treviño) BamfMatcher: allow overriding desktop with the environment var BAMF_DESKTOP_FILE_HINT 2016-06-01 Marco Trevisan (Treviño) BamfMatcher, BamfLegacyWindow: ignore PIDs 0 and 1. 2016-06-01 Marco Trevisan (Treviño) BamfMatcher: allow overriding desktop with the environment var BAMF_DESKTOP_FILE_HINT When such environment variable is exported on the parent process of a window, we use it to override the matching system. 2016-06-01 Marco Trevisan (Treviño) BamfMatcher: also try to use methods to override desktop files if class matching failed 2016-05-16 CI Train Bot Releasing 0.5.3~bzr0+16.10.20160516-0ubuntu1 2016-05-16 Marco Trevisan (Treviño) bamfdaemon-dbus-runner: don't try to start again if already running Fixes: #1532226, #1581896 Approved by: Andrea Azzarone 2016-04-28 Marco Trevisan (Treviño) bamfdaemon-dbus-runner: don't try to start again if already running 2016-04-15 CI Train Bot Releasing 0.5.3~bzr0+16.04.20160415-0ubuntu1 2016-04-15 Marco Trevisan (Treviño) BamfApplication: correctly set a main child when handling windows Fixes a regression in Application.DesktopLess.MainChild.NormalPriority test. Approved by: Andrea Azzarone 2016-04-08 Marco Trevisan (Treviño) BamfApplication: correctly set a main child when handling windows Fixes a regression in Application.DesktopLess.MainChild.NormalPriority test. 2016-04-15 Andrea Azzarone BamfWindow: Export window actions menu using dbusmenu Fixes: #1570812 Approved by: Marco Trevisan (Treviño) 2016-04-12 Andrea Azzarone Merge with lp:~3v1n0/bamf/action-menus-test-fix 2016-04-12 Marco Trevisan (Treviño) BamfWindow: use "Window actions" for menu parent 2016-04-12 Marco Trevisan (Treviño) BamfLegacyWindowTest: implement dummy get_action_menu 2016-04-12 Andrea Azzarone Merge with lp:~3v1n0/bamf/action-menu-unref-unactive 2016-04-09 Marco Trevisan (Treviño) BamfWindow: only export action menus on active windows and keep them around for some focus cycles We only export to the bus the action menus of the last two focused windows, as we don't need others. 2016-04-12 Andrea Azzarone Merge with lp:~3v1n0/bamf/action-menu-tuning 2016-04-09 Marco Trevisan (Treviño) BamfWindow: ensure static list of bamf windows is initialized as NULL 2016-04-09 Marco Trevisan (Treviño) BamfLegacyWindow: remove unused opened function 2016-04-09 Marco Trevisan (Treviño) BamfWindow: use legacy window action menu feature. And initialize dbusmenu only for relevant windows 2016-04-09 Marco Trevisan (Treviño) BamfLegacyWindow: add get_action_menu function, to reuse menu around We create a menu and we keep it around until its visilbe or there's another customer for it 2016-04-09 Marco Trevisan (Treviño) debian/control: no need for libdbusmenu-glib-dev 2016-04-09 Marco Trevisan (Treviño) BamfXUtil: add some code cleanups 2016-04-09 Marco Trevisan (Treviño) BamfLegacyWindow: don't try to open more than an action menu at once 2016-04-08 Andrea Azzarone g_return_if_fail makes tests fail. 2016-04-08 Andrea Azzarone Add safe check for tests. 2016-04-08 Andrea Azzarone Depends on libdbusmenu-gtk3-dev. 2016-04-07 Andrea Azzarone Off by default. 2016-04-07 Andrea Azzarone Update debian/control and debian/rules 2016-04-06 Andrea Azzarone Merge with trunk. 2016-04-06 Andrea Azzarone Make dbusmenu optional. 2016-04-06 Andrea Azzarone Export window actions menu using dbusmenu. 2016-03-31 CI Train Bot Releasing 0.5.3~bzr0+16.04.20160331-0ubuntu1 2016-03-31 Rico Tzschichholz BamfApplication: bind window-{added,removed} signals to child-{added,removed} ones And deprecate dbus Window{Added,Removed} signals as well Approved by: Andrea Azzarone 2016-03-30 Rico Tzschichholz BamfApplication: avoid chaining-up signals. Just use child-{added,removed} ones 2016-03-29 Marco Trevisan (Treviño) libbamf, BamfApplication: deprecate Window{Added,Removed} signals and use child-added 2016-03-29 Marco Trevisan (Treviño) BamfApplication: bind window-{added,removed} signals to child-{added,removed} ones 2016-03-29 Marco Trevisan (Treviño) BamfView: ensure child-added is emitted for later exported children 2016-03-29 Marco Trevisan (Treviño) BamfView: remove unused internal signals 2016-03-22 CI Train Bot Releasing 0.5.3~bzr0+16.04.20160322.1-0ubuntu1 2016-03-22 Marco Trevisan (Treviño) BamfMatcher: avoid to register apps with invalid (empty or not existing) destkop files Fixes: #1560490 Approved by: Andrea Azzarone 2016-03-22 Marco Trevisan (Treviño) BamfMatcher: avoid to register apps with invalid (empty or not existing) destkop files 2016-03-22 Rico Tzschichholz BamfView: Fix ABI break caused by r625 Fixes: #1560486 Approved by: Marco Trevisan (Treviño) 2016-03-22 Rico Tzschichholz Fix ABI break caused by r625 2016-03-21 CI Train Bot Releasing 0.5.3~bzr0+16.04.20160321-0ubuntu1 2016-03-21 Andrea Azzarone BamfView: add "starting" property which is true when an application has been launched Fixes: #676457 Approved by: Marco Trevisan (Treviño), PS Jenkins bot 2016-03-21 Andrea Azzarone Merge with lp:~3v1n0/bamf/sn-fixes 2016-03-21 Marco Trevisan (Treviño) debian/changelog: include bug # 2016-03-21 Marco Trevisan (Treviño) BamfLegacyScreen: fix white space 2016-03-21 Marco Trevisan (Treviño) BamfControl: call bamf_matcher_set_starting_desktop_file on desktop app info launched signal 2016-03-21 Marco Trevisan (Treviño) BamfMatcher: add bamf_matcher_set_starting_desktop_file 2016-03-21 Marco Trevisan (Treviño) BamfApplication: mark app as user visible when starting, otherwise reload flags and close it if not running 2016-03-21 Marco Trevisan (Treviño) BamfMatcher: mark apps as not starting when launch is completed or failing 2016-03-21 Marco Trevisan (Treviño) BamfView: wait some time before marking a view as not being started We wait 15 seconds before unsetting a view as not starting, if it wasn't already running 2016-03-21 Marco Trevisan (Treviño) BamfLegacyScreen: add WINDOW_OPENING_COMPLETED signal and remove starting timeouts 2016-02-29 Andrea Azzarone Properly remove deprecated methods. 2016-02-29 Andrea Azzarone And again. 2016-02-29 Andrea Azzarone Properly bump version. 2016-02-29 Andrea Azzarone Bump version and update symbols. 2016-02-29 Andrea Azzarone Add a timeout to avoid infinite starting animation in case of failing. 2016-02-25 Andrea Azzarone Remove useless space. 2016-02-25 Andrea Azzarone Remove two paddings to avoid ABI break. 2016-02-25 Andrea Azzarone Remove deprecated methods. 2016-02-25 Andrea Azzarone Merge with trunk. 2016-01-20 Andrea Azzarone Fix style. 2016-01-20 Andrea Azzarone Set as visible if it's starting. 2016-01-19 Andrea Azzarone Add starting property. 2016-01-19 Andrea Azzarone Add window-opening signal to legacy screen. 2016-01-19 Andrea Azzarone Build with sn lib. 2015-12-17 CI Train Bot Releasing 0.5.2~bzr0+16.04.20151217-0ubuntu1 2015-12-17 Marco Trevisan (Treviño) BamfMatcher: don't assign no-display desktop files to windows by default when launched Fixes: #1519376 Approved by: PS Jenkins bot, Andrea Azzarone 2015-11-24 Marco Trevisan (Treviño) BamfMatcher: when registering a PID ensure that the window hint is set only for target window If that exists... Otherwise we were reiterating over all the windows for no reason. 2015-11-24 Marco Trevisan (Treviño) TestMatcher: verify nodisplay desktop files being ignored when registering PID 2015-11-24 Marco Trevisan (Treviño) BamfMatcher: don't assign no-display desktop files to windows by default when launched 2015-12-10 CI Train Bot Releasing 0.5.2~bzr0+16.04.20151210-0ubuntu1 2015-12-10 Marco Trevisan (Treviño) BamfDaemon: add upstart session support Approved by: Andrea Azzarone, PS Jenkins bot 2015-11-19 Marco Trevisan (Treviño) bamfdaemon: make start/stop depending on hud and unity-panel-service 2015-11-19 Marco Trevisan (Treviño) data: add bamfdaemon-dbus-runner, to run the daemon using upstart if possible 2015-11-06 Marco Trevisan (Treviño) BamfDaemon: add upstart support 2015-11-04 CI Train Bot Releasing 0.5.2~bzr0+16.04.20151104-0ubuntu1 2015-11-04 Marco Trevisan (Treviño) debian/libbamf3-2.symbols: use 0replaceme trick to get proper symbols Approved by: Didier Roche 2015-11-04 Marco Trevisan (Treviño) debian/libbamf3-2.symbols: use 0replaceme trick to get proper symbols 2015-11-04 Marco Trevisan (Treviño) BamfMatcher: update special g-c-c code to unity-control-center Fixes: #1511481 Approved by: Andrea Azzarone 2015-11-03 Marco Trevisan (Treviño) BamfMatcher: revert change to update app desktop file on u-c-c update, it might break launcher 2015-10-30 Marco Trevisan (Treviño) TestApplication: use unity-control-center binary 2015-10-29 Marco Trevisan (Treviño) TestMatcher: fix tests to use unity-control-center 2015-10-29 Marco Trevisan (Treviño) BamfMatcher: update control center desktop file instead of reopening a window 2015-10-29 Marco Trevisan (Treviño) BamfMatcher: update special g-c-c code to unity-control-center 2015-11-04 Marco Trevisan (Treviño) libBAMF: cache active{window,application} and be smarter in reusing known resources Add new methods in matcher, view and application. Approved by: PS Jenkins bot, Christopher Townsend 2015-11-03 Marco Trevisan (Treviño) debian/gir1.2-bamf-3.install: only support multi-arch 2015-10-28 Marco Trevisan (Treviño) Merging with trunk 2015-10-28 Marco Trevisan (Treviño) Libbamf: revert soname change 2015-06-12 Marco Trevisan (Treviño) libbamf, BamfMatcher: use a g_warning not to crash if matcher can't be reached 2015-05-29 Marco Trevisan (Treviño) debian/changelog: setting distro as UNRELEASED 2015-04-22 Marco Trevisan (Treviño) BamfView: fix virtual annotation to respect new standard 2015-04-22 Marco Trevisan (Treviño) BamfApplication: fix a typo in Return annotation 2015-04-22 Marco Trevisan (Treviño) debian/control: add hicolor-icon-theme ad build dependency 2015-04-22 Marco Trevisan (Treviño) Makefile.am: tests, use realpath to fix tests when using builddir != srcdir 2015-04-22 Marco Trevisan (Treviño) gir1.2-bamf-3.install: work with both multi-arch and not 2015-04-22 Marco Trevisan (Treviño) debian: bump version to 0.5.2~bzr and SONAME 2015-04-22 Marco Trevisan (Treviño) configure.ac: define LIBBAMF_SONAME in a global place 2015-04-21 Marco Trevisan (Treviño) BamfView: rename steal_children to peek_children As we don't steal anything... Also use it when initializing a view and fix get_children class usage. 2015-04-21 Marco Trevisan (Treviño) BamfMatcher: try harder to get a value in get_window_for_xid 2015-04-21 Marco Trevisan (Treviño) BamfApplication: add improve contains_xid method to get_window_for_xid It's just better to return something instead. 2015-04-21 Marco Trevisan (Treviño) BamfMatcher: try to update cached active application when active window changes So when we emit the ACTIVE_WINDOW_CHANGED signal, the active appliaction has already been updated. 2015-04-21 Marco Trevisan (Treviño) BamfView: fix transfer annotation on bamf_view_steal_children 2015-04-21 Marco Trevisan (Treviño) BamfMatcher: add bamf_matcher_get_window_for_xid 2015-04-21 Marco Trevisan (Treviño) BamfFactory: add ability to fetch cached window for a given XID 2015-04-21 Marco Trevisan (Treviño) BamfApplication: define bamf_application_contains_xid 2015-04-21 Marco Trevisan (Treviño) BamfView: add bamf_view_has_child 2015-04-21 Marco Trevisan (Treviño) BamfApplication: use bamf_view_steal_children to get xids, before calling DBus 2015-04-21 Marco Trevisan (Treviño) BamfView: add bamf_view_steal_children This will allow to free these lists multiple times 2015-04-21 Marco Trevisan (Treviño) BamfView: unref a removed view only after that it has been emitted The view might still be alive, but it's better to be safe 2015-04-21 Marco Trevisan (Treviño) BamfApplication: optimize get_windows, just remove views that aren't windows Quite unlikely to happen. 2015-04-21 Marco Trevisan (Treviño) BamfMatcher: cache active {window,application} and call dbus method only when needed 2015-04-21 Marco Trevisan (Treviño) BamfFactory: don't return closed views matching xid And disconnect from view closed events on disposal. 2015-04-21 Marco Trevisan (Treviño) libbamf, BamfMatcher: use cached apps to check if an app is running (before of dbus call) 2015-04-21 Marco Trevisan (Treviño) BamfMatcher: try to use factory before of dbus calls in bamf_matcher_get_application_for_xid 2015-04-21 Marco Trevisan (Treviño) BamfFactory: add _bamf_factory_app_for_xid It allows to check if we already know an app by one of its children XID 2015-06-27 CI Train Bot Releasing 0.5.2~bzr0+15.10.20150627.1-0ubuntu1 2015-06-27 Stephen M. Webb fixed Ubuntu packaging for multi-arch Fixes: #1415052 2015-01-27 Stephen M. Webb merged lp:~larsu/bamf/lp1407711 to pick up an unrelated change for Ubuntu lcov version bump 2015-01-27 Stephen M. Webb move Ubuntu GIR packaging to multi-arch 2015-06-27 Iain Lane Bump gobject-introspection build-dep to the version which installed typelib files in the multiarch libdir Approved by: Marco Trevisan (Treviño) 2014-10-30 Iain Lane Bump gobject-introspection BD to ≥ 1.41.4-1~, to match versions which started to install typelib files into the MA libdir 2014-10-30 Iain Lane Install typelib files into MA libdir 2015-04-21 Marco Trevisan (Treviño) configure.ac: development version bump to 0.5.2 2015-04-15 Marco Trevisan (Treviño) Releasing BAMF-0.5.1 2015-02-02 CI Train Bot Releasing 0.5.1+15.04.20150202-0ubuntu1 2015-02-02 Marco Trevisan (Treviño) BamfMatcher: rename set our atom to _BAMF_DESKTOP_FILE It has never been standard Approved by: Lars Uebernickel 2015-02-02 Marco Trevisan (Treviño) BamfMatcher: rename set our atom to _BAMF_DESKTOP_FILE It has never been standard 2015-02-02 Lars Uebernickel Matcher: use desktop file path when matching on _GTK_APPLICATION_ID Previously, bamf_application_get_application_desktop_file() would return the bare id in those cases. Approved by: Marco Trevisan (Treviño) 2015-02-02 Marco Trevisan matcher: look for app ids only if desktop_file is not set 2015-01-29 Lars Uebernickel Matcher: fix memory leak 2015-01-29 Lars Uebernickel Matcher: use desktop file path when matching on _GTK_APPLICATION_ID Previously, bamf_application_get_application_desktop_file() would return the bare id in those cases. 2015-01-28 CI Train Bot Releasing 0.5.1+15.04.20150128-0ubuntu1 2015-01-28 Andrea Azzarone Replace gtk_icon_theme_has_icon with gtk_icon_theme_lookup_icon. Fixes: #1407192 Approved by: Marco Trevisan (Treviño) 2015-01-21 Andrea Azzarone Minor change. 2015-01-16 Andrea Azzarone Replace gtk_icon_theme_has_icon with gtk_icon_theme_lookup_icon. 2015-01-28 Lars Uebernickel Matcher: honor the _GTK_APPLICATION_ID xprop And give it priority over _NET_WM_DESKTOP_FILE if the application has a matching desktop file installed. Fixes: #1407711 Approved by: Marco Trevisan (Treviño) 2015-01-12 Lars Uebernickel m4: update accepted lcov versions 2015-01-12 Lars Uebernickel Matcher: fix a memory leak 2015-01-10 Lars Uebernickel Matcher: honor the _GTK_APPLICATION_ID xprop And give it priority over _NET_WM_DESKTOP_FILE if the application has a matching desktop file installed. 2015-01-28 Iain Lane Install typelib files into MA libdir 2014-09-25 CI bot Releasing 0.5.1+14.10.20140925-0ubuntu1 2014-09-25 Andrea Azzarone BamfLegacyScreen: Do not show the actions menu for desktop type window. Fixes: 1342609 Approved by: Marco Trevisan (Treviño) 2014-09-11 Andrea Azzarone Do not show the actions menu for desktop type window. 2014-09-25 Stephen M. Webb sync'd packaging with downstream Ubuntu 2014-04-09 CI bot Releasing 0.5.1+14.04.20140409-0ubuntu1 2014-04-09 Iain Lane BamfMatcher: fix prefix regex for pythonX support Fix preifx regex (used for converting /usr/bin/python[stuff] foo into foo) to work with pythonX as well as python and pythonX.Y 2014-04-09 Iain Lane Fix preifx regex (used for converting /usr/bin/python[stuff] foo into foo) to work with pythonX as well as python and pythonX.Y 2014-04-08 CI bot Releasing 0.5.1+14.04.20140408-0ubuntu1 2014-04-08 Alexandre Abreu Rip out vestigial webapps code (LP: #1280337) Fixes: 1280337 2014-04-08 Alexandre Abreu re-enable chromium app mode specific bits 2014-04-08 Alexandre Abreu re-enable chromium app mode specific bits 2014-04-07 Alexandre Abreu remove libunity-webapp deps 2014-03-11 CI bot Resync trunk 2014-03-10 Alexandre Abreu Remove old webapp related code since now we dont use browser tab matching anymore. Fixes: https://bugs.launchpad.net/bugs/1289498. Approved by Marco Trevisan (Treviño), David Barth, PS Jenkins bot. 2014-03-10 CI bot Releasing 0.5.1+14.04.20140310-0ubuntu1 2014-03-10 Alexandre Abreu Remove old webapp related code since now we dont use browser tab matching anymore. Fixes: 1289498 2014-03-07 Alexandre Abreu remove webpp test 2014-03-07 Alexandre Abreu remove old webapp stuff 2014-02-14 CI bot Releasing 0.5.1+14.04.20140214.1-0ubuntu1 2014-02-14 CI bot Release trunk to Ubuntu 2014-02-14 Michel Alexandre Salim [Merge] Fix return value of try_create_local_desktop_data. Fixes: https://bugs.launchpad.net/bugs/1280110. Approved by PS Jenkins bot, Michel Alexandre Salim, Stephen M. Webb. 2014-02-14 Michel Alexandre Salim Fix return value of try_create_local_desktop_data The g_return_val_if_fail invocation should return the gboolean value FALSE, not NULL, otherwise build fails when warnings are treated as errors 2014-02-14 Marco Trevisan (Treviño) BamfLegacyScreen: When in Unity monitor for compiz ClientMessage's to show action menu If we get a _COMPIZ_TOOLKIT_ACTION client message with the internal value _COMPIZ_TOOLKIT_ACTION_WINDOW_MENU, then we are requested by compiz to show the window action menu, and thus let's ask the proper BamfLegacyWindow to do that, thanks to libwnck. Fixes: https://bugs.launchpad.net/bugs/1280042. Approved by Brandon Schaefer, PS Jenkins bot. 2014-02-14 Marco Trevisan (Treviño) BamfLegacyScreen: When in Unity monitor for compiz ClientMessage's to show action menu If we get a _COMPIZ_TOOLKIT_ACTION client message with the internal value _COMPIZ_TOOLKIT_ACTION_WINDOW_MENU, then we are requested by compiz to show the window action menu, and thus let's ask the proper BamfLegacyWindow to do that, thanks to libwnck. 2014-02-14 Marco Trevisan (Treviño) BamfLegacyWindow: add function to show the window action menu, trough libwnck 2014-01-10 Ken VanDine Sync changes uploaded to the archive back to trunk . Approved by PS Jenkins bot, Robert Bruce Park. 2014-01-09 Ken VanDine BamfView: unset active_changed_idle on callback 2014-01-09 Marco Trevisan (Treviño) BamfView: unset active_changed_idle on callback 2014-01-08 Ken VanDine updated lcov versions in gcov.m4 2014-01-07 Ken VanDine bamf-legacy-window-test.c: Don't use 'return' with a value, in function returning void. 2013-11-25 Automatic PS uploader Releasing 0.5.1+14.04.20131125-0ubuntu1 (revision 588 from lp:bamf). Approved by PS Jenkins bot. 2013-11-25 Automatic PS uploader Releasing 0.5.1+14.04.20131125-0ubuntu1, based on r588 2013-10-29 Marco Trevisan (Treviño) BamfXutils: trap the X errors when doing async X calls. Fixes: https://bugs.launchpad.net/bugs/1193714. Approved by PS Jenkins bot, Christopher Townsend. 2013-10-28 Marco Trevisan (Treviño) BamfXutils: trap the X errors when doing async X calls 2013-10-11 Automatic PS uploader Releasing 0.5.1+13.10.20131011-0ubuntu1 (revision 586 from lp:bamf). Approved by PS Jenkins bot. 2013-10-11 Automatic PS uploader Releasing 0.5.1+13.10.20131011-0ubuntu1, based on r586 2013-10-10 Marco Trevisan (Treviño) BamfView: reload the view children everytime it changes dbus path Without doing it we could have children-less views in case we have just re-matched a view with a different dbus path (this happens in general for desktop-less applications), because the proxy won't be fast enough to catch the signal to update the inner children list. Fixes: https://bugs.launchpad.net/bugs/1238064. Approved by Christopher Townsend, PS Jenkins bot. 2013-10-10 Marco Trevisan (Treviño) BamfView: don't leak in case we're replacing the cached children list Unlikely to happen, but it's better to be safe. :) 2013-10-10 Marco Trevisan (Treviño) BamfView: reload the view children everytime it changes dbus path Without doing it we could have children-less views in case we have just re-matched a view with a different dbus path (this happens in general for desktop-less applications), because the proxy won't be fast enough to catch the signal to update the inner children list. 2013-08-30 Automatic PS uploader Releasing 0.5.1+13.10.20130830-0ubuntu1 (revision 584 from lp:bamf). Approved by PS Jenkins bot. 2013-08-30 Automatic PS uploader Releasing 0.5.1+13.10.20130830-0ubuntu1, based on r584 2013-08-30 Marco Trevisan (Treviño) Releasing Bamf-0.5.0 2013-08-22 Automatic PS uploader Releasing 0.5.0+13.10.20130822.5-0ubuntu1 (revision 582 from lp:bamf). Approved by PS Jenkins bot. 2013-08-22 Automatic PS uploader Releasing 0.5.0+13.10.20130822.5-0ubuntu1, based on r582 2013-08-21 Marco Trevisan (Treviño) BamfLegacyScreen: use bigger icons size by default libwnck would just use 32 and 16 sized icons, while we can safely use bigger versions. Fixes: https://bugs.launchpad.net/bugs/1214426. Approved by PS Jenkins bot, Andrea Azzarone. 2013-08-21 Marco Trevisan (Treviño) Merging with trunk 2013-08-21 Marco Trevisan (Treviño) debian/control: depend on libwnck-3 3.4.7 2013-08-20 Marco Trevisan (Treviño) BamfLegacyScreen: use bigger icons size by default libwnck would just use 32 and 16 sized icons, while we can safely use bigger versions 2013-08-20 Marco Trevisan (Treviño) BamfLegacyScreen: shutdown libwnck when closing the screen 2013-08-12 Automatic PS uploader Releasing 0.5.0+13.10.20130812.1-0ubuntu1 (revision 580 from lp:bamf). Approved by PS Jenkins bot. 2013-08-12 Automatic PS uploader Releasing 0.5.0+13.10.20130812.1-0ubuntu1, based on r580 2013-08-10 Stephen M. Webb directly include bamf-tab.h in libbamf.h. Approved by PS Jenkins bot, Brandon Schaefer. 2013-08-09 Stephen M. Webb libbamf.h: add bamf-tab.h header 2013-08-09 Marco Trevisan (Treviño) Bamf: remove Obsolete and never used BamfTabSource/BamfTabProvider This has been implemented using unity webapps properly. Approved by Stephen M. Webb, PS Jenkins bot. 2013-08-09 Marco Trevisan (Treviño) Merge with trunk 2013-08-09 Marco Trevisan (Treviño) docs: Remove BamfTabSource, add BamfTab 2013-08-09 Marco Trevisan (Treviño) libbamf: Fix doc/types generation 2013-08-09 Marco Trevisan (Treviño) BamfView: deprecate bamf_view_get_click_suggestion 2013-08-09 Marco Trevisan (Treviño) Bamf: bump SONAME to libbamf3-2 2013-08-09 Marco Trevisan (Treviño) Bamf: remove Obsolete and never used BamfTabSource/BamfTabProvider This has been implemented using unity webapps properly 2013-08-09 Automatic PS uploader Releasing 0.5.0+13.10.20130809-0ubuntu1 (revision 577 from lp:bamf). Approved by PS Jenkins bot. 2013-08-09 Automatic PS uploader Releasing 0.5.0+13.10.20130809-0ubuntu1, based on r577 2013-08-08 Marco Trevisan (Treviño) BamfApplication: include Path in .desktop file if its working dir is not the default one. Fixes: https://bugs.launchpad.net/bugs/765466. Approved by Christopher Townsend, PS Jenkins bot. 2013-08-08 Marco Trevisan (Treviño) BamfApplication: include X-$XDG_CURRENT_DESKTOPGenerated=true in local .desktop file 2013-08-08 Marco Trevisan (Treviño) TestApplication: verify we properly add Path parameter to local .desktop files when needed 2013-08-08 Marco Trevisan (Treviño) BamfLegacyWindowTest: add working_dir support 2013-08-08 Marco Trevisan (Treviño) BamfApplication: include Path in .desktop file if its working dir is different from current one 2013-08-08 Marco Trevisan (Treviño) TestApplication: verify new .desktop file parameters 2013-08-08 Marco Trevisan (Treviño) BamfApplication: add more fields to the generated .destkop file Such as OnlyShowIn=$XDG_CURRENT_DESKTOP, Encoding and Version 2013-08-08 Marco Trevisan (Treviño) BamfLegacyWindow: add the ability to retrieve the working directory of a window 2013-08-08 Marco Trevisan (Treviño) BamfLegacyWindow: just use g_strjoinv instead of involving a GString to join argv's Also strip the result. 2013-08-08 Marco Trevisan (Treviño) BamfLegacyWindow: fix the dispose function, nullify elemements 2013-08-07 Automatic PS uploader Releasing 0.5.0+13.10.20130807.1-0ubuntu1 (revision 575 from lp:bamf). Approved by PS Jenkins bot. 2013-08-07 Automatic PS uploader Releasing 0.5.0+13.10.20130807.1-0ubuntu1, based on r575 2013-08-07 Marco Trevisan (Treviño) BamfMatcher: ignore known invalid window class values when matching windows And generate better .desktop files for local apps. This will make us life easier with Java. Approved by PS Jenkins bot, Christopher Townsend. 2013-08-07 Marco Trevisan (Treviño) BamfApplication: disable by default the StartupNotification support on local .desktop's 2013-08-07 Marco Trevisan (Treviño) BamfApplication: re-enable the StartupWMClass in .desktop files, but filter out invalid values 2013-08-07 Marco Trevisan (Treviño) BamfMatcher: verify bamf_matcher_is_valid_class_name 2013-08-07 Marco Trevisan (Treviño) BamfMatcher: ignore known invalid window class values when matching windows This will make us life easier for Java apps 2013-08-07 Marco Trevisan (Treviño) BamfApplication: don't save the StartupWMClass in the generate .desktop file 2013-08-07 Marco Trevisan (Treviño) BamfApplication: give more priority to class name when generating desktop file name 2013-08-07 Marco Trevisan (Treviño) BamfDaemon: Use nicer and more compliant dbus object paths for views. Approved by Christopher Townsend, PS Jenkins bot. 2013-08-06 Marco Trevisan (Treviño) Merged add-local-desktop-file into dbus-path-names-cleanup. 2013-08-05 Marco Trevisan (Treviño) Merged add-local-desktop-file into dbus-path-names-cleanup. 2013-08-05 Marco Trevisan (Treviño) libbamf, BamfApplication: emit desktop-file-changed signal when got it from DBus 2013-07-31 Marco Trevisan (Treviño) BamfMatcher: fix a warning we could get on webapp child addition 2013-07-31 Marco Trevisan (Treviño) BamfDaemon: use better names for dbus-paths 2013-08-07 Automatic PS uploader Releasing 0.5.0+13.10.20130807-0ubuntu1 (revision 572 from lp:bamf). Approved by PS Jenkins bot. 2013-08-07 Automatic PS uploader Releasing 0.5.0+13.10.20130807-0ubuntu1, based on r572 2013-08-06 Marco Trevisan (Treviño) BamfControl: add an API to allow generation of local .desktop file for a BamfApplication. Add a bamf_control dbus method that requests to generate a new local .desktop file for the provided application path. In case the application has alredy a desktop file, the request is ignored. Otherwise we use some euristic to generate an hopefully valid file saved in $XDG_DATA_HOME dir. Also added a new DesktopUpdated signal to the BamfApplication DBus interface that is emitted when the .desktop file for an application is set (for now). Fixes: https://bugs.launchpad.net/bugs/753305. Approved by Christopher Townsend, PS Jenkins bot. 2013-08-06 Marco Trevisan (Treviño) debian: update libbamf3-1 symbols file 2013-08-06 Marco Trevisan (Treviño) TestBamfApplication: try create desktop files for applications and verify their content 2013-08-06 Marco Trevisan (Treviño) BamfApplication: rely on class name if available as desktop file basename 2013-08-05 Marco Trevisan (Treviño) libbamf, BamfApplication: emit desktop-file-changed signal when got it from DBus 2013-08-05 Marco Trevisan (Treviño) BamfMatcher: fix a warning we could get on webapp child addition 2013-07-31 Marco Trevisan (Treviño) BamfDaemon: return void dbus calls as soon as possible, no need to wait 2013-07-29 Marco Trevisan (Treviño) BamfApplication: add a proper implementation of create_local_desktop_file We try to create a desktop file with basename that matches the window class or the exec if possible, filling it with the available data from the application main child. 2013-07-29 Marco Trevisan (Treviño) libbamf, BamfControl: add create_local_desktop_file function This is just a wrapper to the DBus call 2013-07-29 Marco Trevisan (Treviño) libbamf, BamfControl: set correct trasnfer value to the get_default function 2013-07-29 Marco Trevisan (Treviño) BamfControl: add CreateLocalDesktopFile method and a simple stub implementation When called BamfControl is supposed to create a local desktop file (if not existent) for the given application. 2013-07-29 Marco Trevisan (Treviño) BamfApplication: add DesktopFileUpdated signal and emit it when the file changes 2013-07-29 Marco Trevisan (Treviño) BamfLegacyWindow: add getter to retrieve the saved mini icon 2013-07-26 Marco Trevisan (Treviño) BamfUnityWebappsApplication: don't crash if we we don't have a desktop file set 2013-07-26 Marco Trevisan (Treviño) BamfLegacyWindow: use GFile to keep track of the saved mini-icon 2013-07-25 Marco Trevisan (Treviño) TestMatcher: add test for get_view_by_path 2013-07-25 Marco Trevisan (Treviño) BamfMatcher: added method get_view_by_path 2013-07-25 Marco Trevisan (Treviño) BamfControl: deprecate OmNomNomDesktopFile dbus method, replaced by InsertDesktopFile 2013-07-25 Automatic PS uploader Releasing 0.5.0+13.10.20130725-0ubuntu1 (revision 570 from lp:bamf). Approved by PS Jenkins bot. 2013-07-25 Automatic PS uploader Releasing 0.5.0+13.10.20130725-0ubuntu1, based on r570 2013-07-24 Automatic PS uploader Releasing 0.5.0+13.10.20130724-0ubuntu1 (revision 566 from lp:bamf). Approved by PS Jenkins bot. 2013-07-24 Automatic PS uploader Releasing 0.5.0+13.10.20130724-0ubuntu1, based on r566 2013-07-24 Marco Trevisan (Treviño) BamfMatcher: add support for the "--desktop_file_hint" exec parameter to override matching This is needed mostly by new Qml applications, but it allows to every app to override its matching by calling it with --desktop_file_hint file-to-use.desktop. Fixes: https://bugs.launchpad.net/bugs/1180402. Approved by Brandon Schaefer, PS Jenkins bot. 2013-07-24 Marco Trevisan (Treviño) TestMatcher: verify --desktop_file_hint exec overriding 2013-07-24 Marco Trevisan (Treviño) BamfMatcher: make desktop file overriding by exec stronger 2013-07-24 Marco Trevisan (Treviño) TestMatcher: verify the --desktop_file_hint when trimming exec 2013-07-24 Marco Trevisan (Treviño) BamfMatcher: add support for the "--desktop_file_hint" exec parameter to override matching This is needed mostly by new Qml applications, but it allows to every app to override its matching by calling it with --desktop_file_hint file-to-use.desktop 2013-07-24 Marco Trevisan (Treviño) BamfLegacyWindow: cache the window Exec string We might use this value multiple times during the BAMF execution, and we don't need to recompute it everytime. Caching looks a good compromise. Approved by Brandon Schaefer, PS Jenkins bot. 2013-07-24 Marco Trevisan (Treviño) BamfLegacyWindow: cache the window Exec string We might use this value multiple times during the BAMF execution, and we don't need to recompute it everytime. Caching looks a good compromise. 2013-07-24 Marco Trevisan (Treviño) BamfMatcher: correctly match QML applications launched with qmlscene or qmlviewer. Fixes: https://bugs.launchpad.net/bugs/1180402. Approved by PS Jenkins bot, Brandon Schaefer. 2013-07-24 Marco Trevisan (Treviño) BamfMatcher: indentation fixes 2013-07-24 Marco Trevisan (Treviño) Merging with trunk 2013-07-23 Marco Trevisan (Treviño) TestMatcher: verify .desktop file matching for QML applications 2013-07-23 Marco Trevisan (Treviño) TestApplication: verify bamf_application_contains_similar_to_window 2013-07-23 Marco Trevisan (Treviño) TestMatcher: verify the Qml Apps matching 2013-07-23 Marco Trevisan (Treviño) BamfMatcher: reduce string copies on alternative matching, ignore it if we miss the prerequisites 2013-07-23 Marco Trevisan (Treviño) BamfApplication: App contains similar to window also if they have NULL classes 2013-07-23 Marco Trevisan (Treviño) TestMatcher: move tests definitions to the bottom 2013-07-23 Marco Trevisan (Treviño) TestMatcher: add QML .desktop verifications 2013-07-23 Marco Trevisan (Treviño) BamfMatcher: ignore any $Var on exec_string 2013-07-23 Marco Trevisan (Treviño) BamfMatcher: add better QML support 2013-07-23 Marco Trevisan (Treviño) TestMatcher: add more path drimming tests 2013-07-23 Marco Trevisan (Treviño) BamfMatcher: add "cli" as bad prefix 2013-07-23 Marco Trevisan (Treviño) "BamfPrivate, no need to define depreaction macro, GLib includes one. Approved by Brandon Schaefer, PS Jenkins bot. 2013-07-20 Marco Trevisan (Treviño) BamfPrivate, no need to define depreaction macro, GLib includes one 2013-07-17 Automatic PS uploader Releasing 0.5.0+13.10.20130717-0ubuntu1 (revision 564 from lp:bamf). Approved by PS Jenkins bot. 2013-07-17 Automatic PS uploader Releasing 0.5.0+13.10.20130717-0ubuntu1, based on r564 2013-07-16 Marco Trevisan (Treviño) BamfApplication: keep track of the application main-window and update name and icon accordingly Applications without a .desktop file should update their name and icon based on their children. So now we try to compute the main window children, and we update name and icon based on it. Fixes: https://bugs.launchpad.net/bugs/751909. Approved by Brandon Schaefer, PS Jenkins bot. 2013-07-16 Marco Trevisan (Treviño) TestBamf, TestApplication: add new tests for main children feature 2013-07-16 Marco Trevisan (Treviño) BamfUnityWebappsObserver: don't try to un-watch an invalid service id 2013-07-16 Marco Trevisan (Treviño) BamfApplication: add main_child getter and ensure we use oldest child on removal 2013-07-16 Marco Trevisan (Treviño) TestApplication: verify app-type setting 2013-07-16 Marco Trevisan (Treviño) BamfApplication: avoid to set the app-type to an invalid value 2013-07-16 Marco Trevisan (Treviño) TestApplication: test type setting 2013-07-16 Marco Trevisan (Treviño) TestApplication: check app type 2013-07-16 Marco Trevisan (Treviño) BamfUnityWebappsObserver: don't initialize the observer when in TestMode 2013-07-16 Marco Trevisan (Treviño) Merged fix-fullpath-icon into leader-window. 2013-06-27 Marco Trevisan (Treviño) BamfApplication: fix a typo, reset the emblems only on desktop-less applications 2013-06-26 Marco Trevisan (Treviño) BamfApplication: code cleanup to get rid of the fake do {} while (FALSE); fix potential memleak 2013-06-26 Marco Trevisan (Treviño) BamfApplication: some code cleanup 2013-06-26 Marco Trevisan (Treviño) BamfApplication: keep only a weak reference on the main_view It should be up to BamView to manage the children ownership, the main_view must be only watched 2013-06-26 Marco Trevisan (Treviño) TestApplication: unref the generated applications 2013-06-26 Marco Trevisan (Treviño) BamfMatcher: keep a reference of the main_child, so we can safely assume it's always an object 2013-06-26 Marco Trevisan (Treviño) BamfApplication: monitor main view name and update the App name if desktopless. If we have a desktopless application we assume that the application name is given by its main childreb, so we need to monitor it. 2013-06-26 Marco Trevisan (Treviño) BamfApplication: use an enum to define application type 2013-06-26 Marco Trevisan (Treviño) BamfApplication: always check the new main child type on removal. avoid to do minor optimization 2013-06-26 Marco Trevisan (Treviño) BamfApplication: don't try to reset name or icon if the application has a desktop file 2013-06-25 Marco Trevisan (Treviño) BamfApplication: keep track of the application main-window and update name and icon accordingly Applications without a .desktop file should update their name and icon based on their children. So now we try to compute the main window children, and we update name and icon based on it. 2013-07-16 Automatic PS uploader Releasing 0.5.0+13.10.20130716-0ubuntu1 (revision 562 from lp:bamf). Approved by PS Jenkins bot. 2013-07-16 Automatic PS uploader Releasing 0.5.0+13.10.20130716-0ubuntu1, based on r562 2013-07-16 Marco Trevisan (Treviño) BamfApplication: if the .desktop file contains the full-path of an icon we should use it If the parsed icon is a file, then we just use it without asking gtk if it's valid for theme. . Fixes: https://bugs.launchpad.net/bugs/1201408. Approved by PS Jenkins bot, Brandon Schaefer. 2013-07-16 Marco Trevisan (Treviño) TestApplication: verify if bamf loads the correct icon when using a the full path 2013-07-16 Marco Trevisan (Treviño) BamfApplication: if the .desktop file contains the full-path of an icon we should use it If the parsed icon is a file, then we just use it without asking gtk if it's valid for theme. 2013-06-28 Automatic PS uploader Releasing 0.5.0+13.10.20130628-0ubuntu1 to ubuntu. Approved by PS Jenkins bot. 2013-06-28 Automatic PS uploader Releasing 0.5.0+13.10.20130628-0ubuntu1, based on r560 2013-06-26 Marco Trevisan (Treviño) BamfFactory: remove the local_views list, we don't need that anymore Having them tracked on allocated_views list is enough, and fixes an issue as explained on bug #1193559. Fixes: https://bugs.launchpad.net/bugs/1193449. Approved by PS Jenkins bot, Andrea Azzarone. 2013-06-21 Marco Trevisan (Treviño) BamfFactory: remove the local_views list, we don't need that anymore Having them tracked on allocated_views list is enough, and fixes 2013-06-26 Marco Trevisan (Treviño) BamfApplication: try to use a window icon if the computed icon belongs to a "generic" app Added a bunch of new BamfApplication tests for icon. Fixes: https://bugs.launchpad.net/bugs/768931, https://bugs.launchpad.net/bugs/1007383. Approved by Brandon Schaefer, PS Jenkins bot. 2013-06-21 Marco Trevisan (Treviño) TestBamf: add local icon directory and prepend it to theme to allow testing 2013-06-21 Marco Trevisan (Treviño) TestLibBamf, Makefile.am: fix make distcheck 2013-06-21 Marco Trevisan (Treviño) TestApplication: add tests for generic icons ovverriding 2013-06-21 Marco Trevisan (Treviño) TestApplication: add desktop-less icon priority test 2013-06-21 Marco Trevisan (Treviño) TestApplication: add test to check the icon taken from window embedded one 2013-06-21 Marco Trevisan (Treviño) BamfLegacyWindowTest: add icon property, and override save_mini_icon 2013-06-21 Marco Trevisan (Treviño) BamfLegacyWindow: make save_mini_icon overridable 2013-06-21 Marco Trevisan (Treviño) TestApplication: add tests to check desktop-less application icons by class or exec 2013-06-21 Marco Trevisan (Treviño) TestApplication: check also for valid and invalid icons 2013-06-21 Marco Trevisan (Treviño) BamfApplication: set fallback-icon if we have an invalid icon on desktop file 2013-06-20 Marco Trevisan (Treviño) BamfApplication: always try to use the more specific icon we have, if the application is "generic" And by "generic" application we mean launched using a black-listed prefix launcher such as python. Also use the more specific trimmed exec instead of the full exec string to retrieve the icon. Also, fix a memory leak. 2013-06-20 Marco Trevisan (Treviño) BamfMatcher: export in header some utility functions to check exec or process 2013-06-26 Marco Trevisan (Treviño) BamfMatcher: ignore registered .desktop files that are in an autostart-folder. Fixes: https://bugs.launchpad.net/bugs/1193502. Approved by PS Jenkins bot, Andrea Azzarone. 2013-06-25 Marco Trevisan (Treviño) TestMatcher: add test for registering desktop files for pid 2013-06-25 Marco Trevisan (Treviño) BamfMatcher: use a better type for registering desktop files by PID 2013-06-25 Marco Trevisan (Treviño) TestMatcher: add autostart file loading 2013-06-25 Marco Trevisan (Treviño) TestMatcher: add is_autostart_desktop_file tests 2013-06-25 Marco Trevisan (Treviño) TestMatcher: move test initialization to the bottom of the file 2013-06-25 Marco Trevisan (Treviño) BamfMatcher: ignore registered .desktop files that are in an autostart-folder 2013-06-19 Marco Trevisan (Treviño) BamfDaemon, LibBamf: add icon property to store the BamfView icon and notify about its changes. New tests added. Approved by Brandon Schaefer, PS Jenkins bot. 2013-06-19 Marco Trevisan (Treviño) BamfView: remove the useless getters from Class Also properly initialize signals adding default handlers 2013-06-19 Marco Trevisan (Treviño) LibBamf, BamfView: use icon property to get its value and notifications, deprecate method 2013-06-19 Marco Trevisan (Treviño) TestView: add tests to verify a BamfView icon events 2013-06-19 Marco Trevisan (Treviño) TestView: re-use test name definition on declaration macros 2013-06-19 Marco Trevisan (Treviño) TestView: add tests to verify the view icon (using macros) 2013-06-19 Marco Trevisan (Treviño) BamfDaemon, BamfView: use a dbus-property to manage the view icon 2013-06-19 Marco Trevisan (Treviño) BamfPrivate: define some common strings between library and daemon 2013-06-19 Marco Trevisan (Treviño) BamfDaemon, LibBamf: Make the BamfView's name a property, deprecated method+signal. Approved by Brandon Schaefer, PS Jenkins bot. 2013-06-19 Marco Trevisan (Treviño) BamfView: deprecate NameChanged signal (not Icon method) 2013-06-19 Marco Trevisan (Treviño) TestView: add name-changed event tests 2013-06-19 Marco Trevisan (Treviño) TestView: some cleanup 2013-06-19 Marco Trevisan (Treviño) TestView: add macro to build exported-events tests 2013-06-19 Marco Trevisan (Treviño) TestView: move test suite initialization at the bottom of the file In this way it's easier to integrate it 2013-06-19 Marco Trevisan (Treviño) BamfView: use a macro to generate tests for boolean properties events 2013-06-19 Marco Trevisan (Treviño) TestView: use macros to define tests that have similar pattern for boolean properties 2013-06-19 Marco Trevisan (Treviño) TestView: add test for active event exported 2013-06-19 Marco Trevisan (Treviño) BamfView: use always the same data for boolean test results 2013-06-19 Marco Trevisan (Treviño) TestView: test the view properties before and after being exported Added tests for missing properties as well 2013-06-19 Marco Trevisan (Treviño) BamfView: use the new dbus property for getting the name and signaling its changes 2013-06-19 Marco Trevisan (Treviño) Daemon, BamfView: correctly notify cached properties when registering a new view 2013-06-19 Marco Trevisan (Treviño) Merged class-rematch into more-dbus-properties. 2013-06-18 Marco Trevisan (Treviño) Daemon, BamfView: use a dbus-property to handle the view name 2013-06-18 Marco Trevisan (Treviño) BamfView: use macros to generate duplicated code to get/set properties 2013-06-18 Marco Trevisan (Treviño) BamfView: rename user_visible() to is_user_visible() 2013-06-18 Marco Trevisan (Treviño) BamfView: temporary save cached properties on a BamfViewPropCache struct This allows to keep this duplicated data around only until strictly needed to notify our dbus clients. 2013-06-18 Marco Trevisan (Treviño) BamfApplication: fix doc-string for get_application_menu 2013-06-18 Marco Trevisan (Treviño) BamfApplication: small header cleanup 2013-06-18 Marco Trevisan (Treviño) BamfApplication: set the dbus-method ApplicationMenu as deprecated, and reflect it in library 2013-06-18 Marco Trevisan (Treviño) BamfPrivate: add macros to ignore GCC warnings and deprecated symbols 2013-06-19 Automatic PS uploader Releasing 0.5.0daily13.06.19-0ubuntu1 to ubuntu. Approved by PS Jenkins bot. 2013-06-19 Automatic PS uploader Releasing 0.5.0daily13.06.19-0ubuntu1, based on r554 2013-06-18 Marco Trevisan (Treviño) BamfMatcher: If a Window has changed its class, then we try to rematch it This is mostly the case of LibreOffice, but if a window has changed its class, then we should try to re-match, checking if now it can be matched by a new application. If this is the case, then we remove the window from the previous application (that may eventually be closed) and we add it to the new one. Thanks to this we can finally remove a lot of libreoffice-only related code. Approved by Brandon Schaefer, PS Jenkins bot. 2013-06-18 Marco Trevisan (Treviño) BamfMatcher: use g_ascii_strncasecmp to compare LO and OO classes 2013-06-18 Marco Trevisan (Treviño) BamfMatcher: ref/unref a win before/after switching its parent application 2013-06-18 Marco Trevisan (Treviño) Merging with trunk 2013-04-17 Marco Trevisan (Treviño) Merge with trunk 2013-04-17 Marco Trevisan (Treviño) BamfMatcher: use bamf_application_get_window when possible 2013-04-17 Marco Trevisan (Treviño) TestMatcher: update the libreoffice matching test to the new code 2013-04-17 Marco Trevisan (Treviño) BamfMatcher: If a Window has changed its class, then we try to rematch it This is mostly the case of LibreOffice, but if a window has changed its class, then we should try to re-match, checking if now it can be matched by a new application. If this is the case, then we remove the window from the previous application (that may eventually be closed) and we add it to the new one. Thanks to this we can finally remove a lot of libreoffice-only related code. 2013-04-17 Marco Trevisan (Treviño) TestApplication: add get_window test 2013-04-17 Marco Trevisan (Treviño) BamfApplication: add getter to retrieve a window from its xid 2013-06-13 Marco Trevisan (Treviño) Bamf: use generic marshallers when creating signals, remove legacy bamf-marshal Improvements to the build system, fixed "make distcheck" (it was still referencing the old bamf.h file) and generation of files when using parallel builds (make -jX). Approved by Brandon Schaefer, PS Jenkins bot. 2013-06-14 Marco Trevisan (Treviño) libbamf: Add missing final new line to Makefile.am.notparallel 2013-06-14 Marco Trevisan (Treviño) LibBamf-Private: generate build files in non-parallel Makefile 2013-06-14 Marco Trevisan (Treviño) Libbamf: Generate files in non-parallel Makefile 2013-06-14 Marco Trevisan (Treviño) LibBamf: remove the bamf-marshal, move to generic marshal. 2013-06-14 Marco Trevisan (Treviño) Daemon: cleanup the last marshal bits 2013-06-13 Marco Trevisan (Treviño) Merging with trunk 2012-10-10 Marco Trevisan (Treviño) BamfDaemon: implicitly always use g_cclosure_marshal_generic as marshaller function 2013-06-13 Marco Trevisan (Treviño) Bamf: the big trailing spaces cleanup! I was just tired of all these spaces around, it's the time to remove them all!. Approved by PS Jenkins bot, Brandon Schaefer. 2013-06-13 Marco Trevisan (Treviño) Non-source-files: Remove other trailing spaces 2013-06-13 Marco Trevisan (Treviño) Merging with lp:~3v1n0/bamf/clean-trailing-spaces 2013-06-13 Marco Trevisan (Treviño) Bamf: the big trailing spaces cleanup! 2013-06-13 Marco Trevisan (Treviño) BamfView: don't try to reload the children if they're empty but we already tried once This finally mutes the "Unable to fetch children" warning... \o/. Fixes: https://bugs.launchpad.net/bugs/943083. Approved by PS Jenkins bot, Andrea Azzarone. 2013-06-13 Marco Trevisan (Treviño) BamfView: don't try to reload the children if they're empty but we already tried once This finally mutes the "Unable to fetch children" warning... \o/ 2013-06-13 Ted Gould Have bamfdaemon depend on the library instead of vice versa. Approved by Marco Trevisan (Treviño), PS Jenkins bot. 2013-06-13 Ted Gould Don't make the lib depend on the daemon, but flip it. 2013-06-13 Marco Trevisan (Treviño) BamfView: disconnect proper callback if a bamf-tab is closed I guess it was a typo, we need to disconnect to the callback we've been connected to before. Approved by PS Jenkins bot, Andrea Azzarone. 2013-06-13 Marco Trevisan (Treviño) BamfView: disconnect proper callback if a bamf-tab is closed I guess it was a typo, we need to disconnect to the callback we've been connected to before... 2013-06-13 Marco Trevisan (Treviño) BamfView: use incremental children caching, delete them only when daemon stops Each view used to cleanup the cached children every time a new one was added or removed. This was needed at the dbus-glib times to handle the case of bamfdaemon restart, but now we can handle this nicely, clening the children up only when this happens. Approved by PS Jenkins bot, Andrea Azzarone. 2013-06-13 Marco Trevisan (Treviño) BamfView: use incremental children caching, delete them only when daemon stops Each view used to cleanup the cached children every time a new one was added or removed. This was needed at the dbus-glib times to handle the case of bamfdaemon restart, but now we can handle this nicely, clening the children up only when this happens. 2013-06-13 Marco Trevisan (Treviño) BamfFactory: fix references of allocated/closed views; improve re-matching of views Now the ownership of the open views is in the hash-table, closed views must be owned by clients (if they want to). The factory also tracks the allocated views until they don't get destroyed to re-use them if possible. Fixes: https://bugs.launchpad.net/bugs/1176524, https://bugs.launchpad.net/bugs/1181717. Approved by Andrea Azzarone, PS Jenkins bot, Ted Gould. 2013-06-13 Marco Trevisan (Treviño) BamfFactory: comment wording fix 2013-06-13 Marco Trevisan (Treviño) BamfFactory: only care about closed views when rematching It's unsafe to try to rematch an allocated view that is not closed, since it could lead to a path change. We were not able do this before since we had no way to get if a view was closed if its remote owner disappeared. With gdbus this is easily possible, instead. 2013-06-13 Marco Trevisan (Treviño) BamfView: set a view closed if the name-owner has changed to an invalid value... This happens when bamf-daemon is killed/closed and thanks with gdbus we can now track this case to handle it properly. 2013-06-13 Marco Trevisan (Treviño) BamfView: make the closed signal to run_last. 2013-06-13 Marco Trevisan (Treviño) BamfFactory: only remove all values from hashtable on dispose, destroy it on finalize 2013-06-13 Marco Trevisan (Treviño) BamfFactory: weak_unref all the allocated views before of being disposed 2013-06-13 Marco Trevisan (Treviño) BamfFactory: register again a view if it is closed 2013-06-13 Marco Trevisan (Treviño) BamfFactory: some code cleanup 2013-06-13 Marco Trevisan (Treviño) BamfFactory: don't allow a view to be closed more than once, unreffing them Also make sure that if we don't have a valid path, we try to remove the view by iterating the hash-table. 2013-06-13 Marco Trevisan (Treviño) BamfFactory: completely move the ownership of the registered views to the HashTable The views are now ref'd when added to it and unreffed on removal. Then it's up to the clients to handle their ownership in other cases. 2013-06-13 Marco Trevisan (Treviño) BamfFactory: add track_view function that is used only to weak_ref allocated views In this way we make sure we only call it once per allocated view, while registration can be done multiple times (for a closed view). 2013-06-12 Marco Trevisan (Treviño) BamfFactory: ignore name-matching if there are multiple views with the same name 2013-06-12 Marco Trevisan (Treviño) debian/changelog: put recent changes under the 0.5.0 revision 2013-06-12 Marco Trevisan (Treviño) Merge with trunk 2013-06-12 Marco Trevisan (Treviño) BamfMatcher: don't define has_tab_with_parent_xid if we don't have web-apps enabled 2013-06-11 Marco Trevisan (Treviño) BamfFactory: use application name comparison if all the other matching fail 2013-06-11 Marco Trevisan (Treviño) BamfView: use statically allocated pspec to notify property changes BamfFactory: some initial cleanup, remove views that have changed their path and use cached children. Approved by PS Jenkins bot, Andrea Azzarone. 2013-06-11 Marco Trevisan (Treviño) BamfView: go back to emit close disgnal only when notified by dbus-proxy Otherwise we could get some warning, need to fix this later. 2013-06-10 Marco Trevisan (Treviño) BamfView: use GParamSpec properties array to initialize and emit notifications 2013-06-10 Marco Trevisan (Treviño) BamfView: notify when the path of a view changes 2013-06-10 Marco Trevisan (Treviño) BamfFactory: rename views to open_views and remove the ones that change path 2013-06-10 Marco Trevisan (Treviño) BamfFactory: use application's chached xids to match similar apps by children 2013-06-10 Marco Trevisan (Treviño) BamfView: code cleanup and fix compilation issues 2013-06-10 Marco Trevisan (Treviño) BamfView: no need anymore to ref/unref on "closed" signal, move the emission in set_closed. 2013-06-10 Marco Trevisan (Treviño) BamfFactory: use connect to the "closed" signal after the default handler In this way the unref will happen after that all the other clients have been notified for the "closed" signal, and they can safely work with their copy of the View. 2013-06-10 Marco Trevisan (Treviño) BamfApplication: indentation fixes 2013-06-08 Marco Trevisan (Treviño) BamfFactory, BamfView: some code cleanup 2013-06-11 Jeremy Bicha debian/control: Have libbamf3-dev depend on gir1.2-bamf-3, Drop build-depends on gir1.2-glib-2.0. Approved by PS Jenkins bot, Mathieu Trudel-Lapierre, Marco Trevisan (Treviño). 2013-06-10 Jeremy Bicha add changelog 2013-06-07 Jeremy Bicha Have libbamf3-dev depend on gir1.2-bamf-3 Drop explicit build-depends on gir1.2-glib-2.0 2013-06-11 Marco Trevisan (Treviño) Reverting revision 540, to get back GDBus based libbamf and DBus properties usage. Fixes: https://bugs.launchpad.net/bugs/697146, https://bugs.launchpad.net/bugs/1180057, https://bugs.launchpad.net/bugs/1180837, https://bugs.launchpad.net/bugs/1188518. Approved by Andrea Azzarone, PS Jenkins bot. 2013-06-08 Marco Trevisan (Treviño) Merging with lp:~3v1n0/bamf/libbamf-gdbus-round2 2013-06-08 Marco Trevisan (Treviño) BamfFactory: ref a view when returning it 2013-06-08 Marco Trevisan (Treviño) debian/changelog: fixing changelog entries to match upstream and gdbus changes 2013-06-08 Marco Trevisan (Treviño) Reverting back to r539 2013-06-10 Marco Trevisan (Treviño) BamfDaemon, LibBamf: Fix compilation errors out from ubuntu. Fixes: https://bugs.launchpad.net/bugs/1176524, https://bugs.launchpad.net/bugs/1186915. Approved by PS Jenkins bot, Christopher Townsend. 2013-06-10 Marco Trevisan (Treviño) configure.ac: don't bother about cast-align or the generated code won't work as expected in ARM buidlds. 2013-06-08 Marco Trevisan (Treviño) LibBamf, BamfApplication: remove a typo (";" after an if statement) Thanks to gcc and new CFLAGS... 2013-06-08 Marco Trevisan (Treviño) BamfMatcher: include abstract bamf-tab.h 2013-06-08 Marco Trevisan (Treviño) configure.ac: use more strict CFLAGS 2013-06-08 Marco Trevisan (Treviño) LibBamf, BamfApplication: define G_KEY_FILE_DESKTOP_KEY_FULLNAME if it's not. 2013-06-10 Marco Trevisan (Treviño) Makefile.am.gtests: kill the launched dbus-daemon after running the tests. Fixes: https://bugs.launchpad.net/bugs/1088696, https://bugs.launchpad.net/bugs/1186915. Approved by Francis Ginther, PS Jenkins bot. 2013-06-08 Marco Trevisan (Treviño) Makefile.am.gtests: kill the launched dbus-daemon after running the tests 2013-06-07 Automatic PS uploader Releasing 0.4.0daily13.06.07-0ubuntu1 to ubuntu. Approved by PS Jenkins bot. 2013-06-07 Automatic PS uploader Releasing 0.4.0daily13.06.07-0ubuntu1, based on r540 2013-06-07 Didier Roche Try reverting intrusive rev 536, 537 and 538 for getting unity back on shape during tests 2013-06-07 Marco Trevisan (Treviño) libbamf, BamfView: Use dbus-properties (both values and signals) It allows to have correct values and signals when they get updated. Deprecating related dbus methods/signals. Approved by Andrea Azzarone, PS Jenkins bot. 2013-06-06 Marco Trevisan (Treviño) LibBamfPrivate: deprecate methods/signals that are now accessible as properties 2013-06-06 Marco Trevisan (Treviño) libbamf, BamfView: Use dbus-properties (both values and signals) It allows to have correct values and signals when they get updated 2013-06-06 Marco Trevisan (Treviño) libBamf: use GDBus proxies to connect to the daemon, move away from dbus-glib! Include a lot of code cleanup, added destruction bits to the BamfFactory. Use GCancellable for the dbus calls to have nicer object destruction. Implement Matcher's GetTab methods (both daemon and library side) and XidsForApplication. Expose signals names as #define'd strings. Fix some library annotations (to have better GIR bindings). Correctly emit property-changed signals for about-to-close view's. Fixes: https://bugs.launchpad.net/bugs/697146, https://bugs.launchpad.net/bugs/1180057, https://bugs.launchpad.net/bugs/1180837. Approved by PS Jenkins bot, Mathieu Trudel-Lapierre, Andrea Azzarone, Brandon Schaefer. 2013-06-06 Marco Trevisan (Treviño) debian/changelog: be more explicit 2013-06-06 Marco Trevisan (Treviño) BamfView: go back to use signals, we'll use properties on upcoming branches... 2013-06-06 Marco Trevisan (Treviño) TestLibBamf: use a weak pointer to make the test stronger 2013-06-05 Marco Trevisan (Treviño) Updated .bzrignore 2013-06-05 Marco Trevisan (Treviño) debian/changelog: bump revision to 0.5.0 2013-06-05 Marco Trevisan (Treviño) BamfMatcher: set the correct element-type when returning list of View's 2013-06-05 Marco Trevisan (Treviño) BamfMatcher: improve docs for get_window_stack_for_monitor 2013-06-05 Marco Trevisan (Treviño) BamfMatcher: unref the factory on finalize 2013-06-05 Marco Trevisan (Treviño) BamfFactory: minor cleanup 2013-06-05 Marco Trevisan (Treviño) BamfFactory: only unref a valid view and ref_sink only floating ones 2013-06-05 Marco Trevisan (Treviño) Daemon, BamfControl: get bus asynchronously and cleanup on destroy 2013-06-05 Marco Trevisan (Treviño) libbamf-private: fix makefile syntax 2013-06-05 Marco Trevisan (Treviño) Merged libbamf-private into libbamf-gdbus. 2013-06-04 Marco Trevisan (Treviño) configure.ac: bump revision to 0.5.0 2013-06-04 Marco Trevisan (Treviño) Various code style fixes 2013-06-04 Marco Trevisan (Treviño) BamfView: use GCancellable also on proxy initialization 2013-06-04 Marco Trevisan (Treviño) BamfMatcher: add GCancellable 2013-06-04 Marco Trevisan (Treviño) Libbamf: use proper types for emitting signals 2013-06-04 Marco Trevisan (Treviño) TestLibBamf: add further Matcher singleton testing 2013-06-04 Marco Trevisan (Treviño) TestLibBamf: add deeper matcher singleton testing 2013-06-04 Marco Trevisan (Treviño) Merged libbamf-private into libbamf-gdbus. 2013-06-04 Marco Trevisan (Treviño) BamfDaemon: remove unneeded tabs on Makefile.am 2013-06-04 Marco Trevisan (Treviño) Merging with parent branch 2013-06-04 Marco Trevisan (Treviño) Merging with lp:~3v1n0/bamf/libbamf-private 2013-06-04 Marco Trevisan (Treviño) Daemon, BamfTab: use "tab" as stable dbus name 2013-06-04 Marco Trevisan (Treviño) LibBamf: move declaration of 'new' functions to bamf-view-private.h Hide one from bamf-tab.h. TODO: hide from .so symbols as well, but this needs some more work 2013-06-04 Marco Trevisan (Treviño) LibBamf: Define a common proxy timeout value in libbamf-private and use it for proxies 2013-06-04 Marco Trevisan (Treviño) debian/control: remove libdbus-glib-dev from build dependencies 2013-06-04 Marco Trevisan (Treviño) TestLibBamf: use BAMF_TEST_MODE and export real PATH 2013-06-04 Marco Trevisan (Treviño) Bamf.h: removed the file, always using libbamf-private definitions 2013-06-04 Marco Trevisan (Treviño) Daemon, Bamf.h: use defininitions of private library 2013-06-04 Marco Trevisan (Treviño) BamfPrivate: define BAMF_DBUS_SERVICE_NAME based on testing environment 2013-06-03 Marco Trevisan (Treviño) LibBamf: ignore some fatal errors during tests 2013-06-01 Marco Trevisan (Treviño) LibbamfTest: check for singleton, add some cleanup 2013-06-01 Marco Trevisan (Treviño) Merging with trunk, fixing errors 2013-06-01 Marco Trevisan (Treviño) BamfView: some code cleanup 2013-05-24 Marco Trevisan (Treviño) BamfView: Cancel the GCancellable if view is closed, unset on dispose Also resume some code cleanup lost during lp:bamf merging 2013-05-24 Marco Trevisan (Treviño) BamfWindow: use GCancellable for all the sync dbus calls 2013-05-24 Marco Trevisan (Treviño) BamfTab: use GCancellable for all the sync dbus calls 2013-05-24 Marco Trevisan (Treviño) BamfApplication: use GCancellable for all the sync dbus calls 2013-05-16 Marco Trevisan (Treviño) BamfView: add GCancellable to be used for all the dbus calls Added also the utility macro CANCELLABLE to make easier to use by clients 2013-05-16 Marco Trevisan (Treviño) BamfTab: removing definitions for unsupported signals 2013-05-16 Marco Trevisan (Treviño) BamfTab: add annotation to functions, allow to generate bindings for request_preview 2013-05-16 Marco Trevisan (Treviño) BamfFactory: remove unneded null initialization 2013-05-15 Marco Trevisan (Treviño) Libbamf: removing build dependency from libbamf-private.la It makes things worse than expected. 2013-05-15 Marco Trevisan (Treviño) Merged libbamf-private into libbamf-gdbus. 2013-05-15 Marco Trevisan (Treviño) BamfTab: fix the preview request async reply 2013-05-15 Marco Trevisan (Treviño) Libbamf: use prefixed _bamf_dbus calls, so that they don't get exported in symbols 2013-05-15 Marco Trevisan (Treviño) Merging with libbamf-private branch, and set the library as build dependency 2013-05-15 Marco Trevisan (Treviño) Merged libbamf-private into libbamf-gdbus. 2013-05-15 Marco Trevisan (Treviño) Merged libbamf-private into libbamf-gdbus. 2013-05-15 Marco Trevisan (Treviño) Merged libbamf-private into libbamf-gdbus. 2013-05-15 Marco Trevisan (Treviño) Merging with lp:~3v1n0/bamf/libbamf-private build fixes 2013-05-15 Marco Trevisan (Treviño) Merged libbamf-private into libbamf-gdbus. 2013-05-15 Marco Trevisan (Treviño) libbamf-private: set the correct name for browser dbus bindings 2013-05-15 Marco Trevisan (Treviño) Merged libbamf-private into libbamf-gdbus. 2013-05-15 Marco Trevisan (Treviño) Daemon, BamfView: flush skeleton signals before emitting closed signal 2013-05-15 Marco Trevisan (Treviño) BamfMatcher: fix the iteration over the returned arrays 2013-05-15 Marco Trevisan (Treviño) BamfTab: make tab properties read-only (we don't really need them as writable) 2013-05-14 Marco Trevisan (Treviño) BamfTab: port to gdbus proxy 2013-05-14 Marco Trevisan (Treviño) Daemon, BamfMatcher: return a list of tabs when TabPaths is called 2013-05-03 Marco Trevisan (Treviño) BamfTab: minor cleanup and trailing spaces removal 2013-05-03 Marco Trevisan (Treviño) lib, BamfView: use DEPRECATED_FOR 2013-05-03 Marco Trevisan (Treviño) Merging with trunk 2012-06-14 Marco Trevisan (Treviño) BamfView: use the properties change notifications instead of dbus signals GDBus codegen give us these notifications for free, we can use them instead of the "old-style" dbus signals 2012-06-14 Marco Trevisan (Treviño) BamfView: check for remote_ready, cache local name, use the proxy object path No need to store the object path, gdbus do that for us; don't reset the proxy if the path has not changed. Also check for closed views in _bamf_view_remote_ready and use it to prevent errors. Also always cache the name. 2012-06-14 Marco Trevisan (Treviño) BamfFactory: correctly populate the registered_view list Plus various code improvements 2012-06-14 Marco Trevisan (Treviño) BamfControl: use g_return_if_fail 2012-06-14 Marco Trevisan (Treviño) BamfWindow: return an unknown window if type if not remote ready Plus add xprop value check 2012-06-14 Marco Trevisan (Treviño) Code spacing cleanup 2012-06-14 Marco Trevisan (Treviño) Daemon, BamfView: cache the properties until we don't export the object At that point, we need to update the dbus skeleton value, so that it will notify the clients emitting the proper signal. 2012-06-14 Marco Trevisan (Treviño) Daemon, BamfView: no need to manually unexport... The skeleton will do it We only have to flush! 2012-06-14 Marco Trevisan (Treviño) Daemon, BamfView: unref the listed interfaces, as requested! 2012-06-14 Marco Trevisan (Treviño) Daemon, BamfView: flush the skeleton signals before unexporting the view 2012-06-14 Marco Trevisan (Treviño) Daemon, BamfView: show each object exportation error 2012-06-13 Marco Trevisan (Treviño) configure.in: remove the dbus-glib-1 dependency 2012-06-13 Marco Trevisan (Treviño) libbamf, BamfTabSource, Makefile.am: move to GDBus 2012-06-05 Marco Trevisan (Treviño) BamfDaemon, BamfApplication: fix some glib warning, remove traling spaces 2012-06-05 Marco Trevisan (Treviño) BamfApplication: use gdbus proxy 2012-06-05 Marco Trevisan (Treviño) BamfDBusBrowser: fix the C prefix on generated code 2012-06-05 Marco Trevisan (Treviño) libbamf, BamfWindow: use globally defined variables for service name 2012-06-05 Marco Trevisan (Treviño) libbamf, BamfMatcher: use globally defined variables for service name and disconnect signals on dispose Plus some cleanups and improvements 2012-06-05 Marco Trevisan (Treviño) libbamf, BamfIndicator: use globally defined variables for service name 2012-06-05 Marco Trevisan (Treviño) libbamf, BamfControl: use globally defined variables for service name 2012-06-05 Marco Trevisan (Treviño) Makefile.am: build lib/libbamf-private as first thing 2012-06-05 Marco Trevisan (Treviño) Merging with trunk 2012-06-05 Marco Trevisan (Treviño) Bamf: move the default dbus names path into bamf-private.h 2012-06-05 Marco Trevisan (Treviño) libbamf*.pc.in: remove the libwnck-3.0 dependency, there's no direct dep on it. Only the daemon depends on that. 2012-05-08 Marco Trevisan (Treviño) BamfIndicator: Ported to gdbus 2012-05-03 Marco Trevisan (Treviño) BamfWindow: rewirite to use the gdbus proxy 2012-05-01 Marco Trevisan (Treviño) BamfView: first raw port to gdbus proxy 2012-05-01 Marco Trevisan (Treviño) Merged with trunk changes... 2011-12-28 Marco Trevisan (Treviño) Makefile: Allow to include only in daemon and lib 2011-12-28 Marco Trevisan (Treviño) LibBamf, BamfControl: moved to GDBus 2011-12-28 Marco Trevisan (Treviño) LibBamf, BamfFactory: add destroy and finalize functions. 2011-12-28 Marco Trevisan (Treviño) LibBamf, BamfFactory: oops... Unref the temporary proxy! 2011-12-28 Marco Trevisan (Treviño) LibBamf, BamfFactory: use a simple gdbus call to query the type of view to create There's no need to create a new empty view just for that purpose. 2011-12-28 Marco Trevisan (Treviño) LibBamf, BamfMatcher: add finalize and dispose functions. 2011-12-28 Marco Trevisan (Treviño) LibBamf, BamfTab: include signal names on header too. 2011-12-28 Marco Trevisan (Treviño) LibBamf: updated the copyright, and add on header files the signal names. 2011-12-28 Marco Trevisan (Treviño) BamfMatcher: removing all the remaining DBus-GLib bits And use the defined signal strings on initialization code too. 2011-12-28 Marco Trevisan (Treviño) Merging with bamfdaemon-gdbus branch. 2011-12-28 Marco Trevisan (Treviño) BamfFactory: use safe casts to BamfApplication 2011-12-28 Marco Trevisan (Treviño) BamfMatcher: let's start speak GDBus! Matcher library ported to GDBus code, using the shared private libs with the gdbus-codegen generated code. Including some code cleanup, and added support for the missing functions. 2013-06-05 Marco Trevisan (Treviño) LibBamfPrivate: add new private library to share code between client and daemon. Approved by PS Jenkins bot, Brandon Schaefer. 2013-06-05 Marco Trevisan (Treviño) Merging with trunk... 2013-06-04 Marco Trevisan (Treviño) Configure.ac: add gtester2xunit checks 2013-06-04 Marco Trevisan (Treviño) Merging with trunk, again... 2013-06-04 Marco Trevisan (Treviño) Merging with trunk, fixing errors 2013-05-15 Marco Trevisan (Treviño) BamfDaemon: removing build dependency from libbamf-private.la It makes things worse than expected. 2013-05-15 Marco Trevisan (Treviño) BamfPrivate: use "_" prefix for _bamf_dbus private functions (not to export them on lib) 2013-05-15 Marco Trevisan (Treviño) BamfPrivate: Makefile, use smarter way to generate source code 2013-05-15 Marco Trevisan (Treviño) Daemon, Makefile: set the private lib as dependency for the daemon building 2013-05-15 Marco Trevisan (Treviño) BamfPrivate: remove the unneeded legacy BamfBrowser interface No one is really implementing or using it 2013-05-15 Marco Trevisan (Treviño) BamfPrivate: Fix Makefile.am indentation 2013-05-15 Marco Trevisan (Treviño) BamfPrivate: remove the "lib/" prefix and fix build outside main directory 2013-05-15 Marco Trevisan (Treviño) Makefile.am: correctly set the main build order 2013-05-15 Marco Trevisan (Treviño) Remove unneeded file 2013-05-02 Marco Trevisan (Treviño) Fix compilation on different directories 2013-05-02 Marco Trevisan (Treviño) Merging with trunk 2012-06-14 Marco Trevisan (Treviño) Merging with trunk 2011-12-27 Marco Trevisan (Treviño) Bamf: add a libbamf-private library to factorize the dbus generated code. 2013-06-04 Mathieu Trudel-Lapierre Fix test-libbamf to properly call gtester2xunit. Approved by PS Jenkins bot, Didier Roche. 2013-06-04 Mathieu Trudel-Lapierre Properly pass the path to gtester.xsl to gtester2xunit. 2013-06-04 Mathieu Trudel-Lapierre Re-add gtester.xsl to tests/, so that the tests can run. 2013-05-31 Timo Jyrinki libbamf: BamfApplication: cache MimeTypes and ApplicationType on favorite and sticky apps. Fixes: https://bugs.launchpad.net/bugs/1183871, https://bugs.launchpad.net/bugs/1183978. Approved by PS Jenkins bot, Brandon Schaefer. 2013-05-31 Marco Trevisan (Treviño) Gtests: use gtester2xunit to generate jenkins friendly test reports 2013-05-31 Marco Trevisan (Treviño) Coverage: clean generated files also if coverage is not configured 2013-05-31 Marco Trevisan (Treviño) Coverage: exclude tests when generating the report 2013-05-31 Marco Trevisan (Treviño) Coverage: set clean-coverage-xml as alias for clean-coverage-gcovr 2013-05-31 Marco Trevisan (Treviño) Coverage: set coverage-xml as alias for coverage-gcovr 2013-05-31 Marco Trevisan (Treviño) tests: include coverage CFLAGS/LDADD or report won't indicate proper values 2013-05-31 Marco Trevisan (Treviño) Makefile.am.gtests: remove sleep, no one likes to sleep when unneed... Really? :) 2013-05-31 Marco Trevisan (Treviño) TestLibBamf: init gtk or the dbus initialization won't work 2013-05-31 Marco Trevisan (Treviño) TestLibBamf: remove unsafe type check on deleted pointer 2013-05-31 Brandon Schaefer TestBamfDaemon: don't check for GLIB type on deleted pointers 2013-05-25 Marco Trevisan (Treviño) Fix make distcheck 2013-05-24 Marco Trevisan (Treviño) libbamf: BamfApplication: cache MimeTypes and ApplicationType on favorite and sticky apps 2013-05-24 Marco Trevisan (Treviño) libbamf, BamfApplication: cache the relevant values when sticking In this way we are sure they are available also if the application is closed. 2013-05-24 Marco Trevisan (Treviño) BamfView: add set_sticky to the BamfViewClass and call it to notify stickyness 2013-05-24 Marco Trevisan (Treviño) Fix make distcheck after moving tests data dir 2013-05-24 Marco Trevisan (Treviño) TestLibBamf: add BamfApplication favorite generation test 2013-05-24 Marco Trevisan (Treviño) TestLibBamf: add BamfApplication skeleton test 2013-05-24 Marco Trevisan (Treviño) Tests: move data under tests/data 2013-05-24 Marco Trevisan (Treviño) Libbamf, BamfApplication: initialize supported mime types and application type for sticky apps 2013-05-24 Marco Trevisan (Treviño) Daemon, BamfApplication: cleanup the mime types fetching 2013-05-08 Automatic PS uploader Releasing 0.4.0daily13.05.08~13.04-0ubuntu1 to ubuntu. Approved by PS Jenkins bot. 2013-05-08 Automatic PS uploader Releasing 0.4.0daily13.05.08~13.04-0ubuntu1, based on r533 2013-05-02 Timo Jyrinki Update raring branch Vcs-Bzr url to 0.4. Approved by PS Jenkins bot, Łukasz Zemczak. 2013-05-01 Timo Jyrinki Set Vcs-Bzr url to 0.4 for this raring branch 2013-05-01 Timo Jyrinki Update raring branch Vcs-Bzr url to 0.4 2013-05-03 Automatic PS uploader Releasing 0.4.0daily13.05.02-0ubuntu1 to ubuntu. Approved by PS Jenkins bot. 2013-05-02 Automatic PS uploader Releasing 0.4.0daily13.05.02-0ubuntu1, based on r533 2013-05-02 Andrea Azzarone Remove functional tests. Approved by PS Jenkins bot, Marco Trevisan (Treviño). 2013-05-02 Andrea Azzarone Remove legacy functional tests. 2013-04-18 Marco Trevisan (Treviño) BamfMatcher: use role and class changes signal to match LibreOffice and g-c-c. Fixes: https://bugs.launchpad.net/bugs/1100554. Approved by Andrea Azzarone, PS Jenkins bot. 2013-04-18 Marco Trevisan (Treviño) BamfLegacyWindowTest: free previous values when setting strings 2013-04-17 Marco Trevisan (Treviño) debian: update changelog and build-dependencies 2013-04-17 Marco Trevisan (Treviño) configure.ac: set libwnck3 dependency to version 3.4.5 2013-04-17 Marco Trevisan (Treviño) TestMatcher: update tests to work with new matcher 2013-04-17 Marco Trevisan (Treviño) BamfLegacyWindowTest: emit class-changed signal when it happens 2013-04-17 Marco Trevisan (Treviño) BamfMatcher: simplify the libreoffice matching code 2013-04-17 Marco Trevisan (Treviño) TestMatcher: update g-c-c test to reflect new matcher 2013-04-17 Marco Trevisan (Treviño) BamfMatcher: use window-role signals and getters for G-C-C integration 2013-04-17 Marco Trevisan (Treviño) BamfLegacyWindowTest: add window role support 2013-04-17 Marco Trevisan (Treviño) BamfLegacyWindow: add role getter function 2013-04-17 Marco Trevisan (Treviño) BamfLegacyWindow: correctly disconnect from all signals 2013-04-17 Marco Trevisan (Treviño) BamfLegacyWindow: add role and class changed signals, use just one callback for most 2013-04-17 Marco Trevisan (Treviño) BamfMatcher: fix a memory leak when trying to associate apps to new desktop files. Fixes: https://bugs.launchpad.net/bugs/1100551, https://bugs.launchpad.net/bugs/1100553, https://bugs.launchpad.net/bugs/1169990. Approved by Andrea Azzarone, PS Jenkins bot. 2013-04-17 Marco Trevisan (Treviño) BamfMatcher: fix typo in list eraser 2013-04-17 Marco Trevisan (Treviño) BamfMatcher: be safer on checking string arrays 2013-04-17 Marco Trevisan (Treviño) BamfLegacyWindow: Use g_file_new_tmp to generate temporary files 2013-04-17 Marco Trevisan (Treviño) BamfMatcher: fix a memory leak when trying to associate apps to new desktop files 2013-04-16 Marco Trevisan (Treviño) BamfMatcher: move the ownership of a chromeless webapp between WM and WebApps Also use new child-{added,removed}-internal signals. Fixes: https://bugs.launchpad.net/bugs/1059475. Approved by PS Jenkins bot, Brandon Schaefer. 2013-04-17 Marco Trevisan (Treviño) Merge with trunk 2013-04-16 Marco Trevisan (Treviño) BamfMatcher: cleanups... 2013-04-16 Marco Trevisan (Treviño) BamfUnityWebappsTab: code cleanup 2013-04-16 Marco Trevisan (Treviño) BamfMatcher: move the ownership of a chromeless webapp between WM and WebApps Also use new child-{added,removed}-internal signals. 2013-04-16 Marco Trevisan (Treviño) BamfUnityWebappsApplication: cleanup 2013-04-16 Marco Trevisan (Treviño) BamfView: add internal-child-{added,removed} signals 2013-04-16 Marco Trevisan (Treviño) BamfUnityWebappsTab: Use default screen windows to set the legacy pointer Connect on closed signal, to nullify the instance. Plus, remove unneeded signals 2013-02-21 Alexandre Abreu Fix chromeless launch for webapps: avoid double matching (browser + individual webapp) 2013-04-03 Automatic PS uploader Releasing 0.4.0daily13.04.03-0ubuntu1 to ubuntu. Approved by PS Jenkins bot. 2013-04-03 Automatic PS uploader Releasing 0.4.0daily13.04.03-0ubuntu1, based on r528 2013-04-02 Marco Trevisan (Treviño) debian/changelog: updated to match last changes 2013-03-28 Marco Trevisan (Treviño) BamfMatcher: make sure that all the no-display desktop files have lower priority. Fixes: https://bugs.launchpad.net/bugs/1161531. Approved by PS Jenkins bot, Brandon Schaefer. 2013-03-28 Marco Trevisan (Treviño) Merging with trunk 2013-03-28 Marco Trevisan (Treviño) Tests: commit missing file 2013-03-28 Marco Trevisan (Treviño) Merging with trunk 2013-03-28 Marco Trevisan (Treviño) Merging with lp:~3v1n0/bamf/class-to-index-file 2013-03-28 Marco Trevisan (Treviño) TestMatcher: add tests to check the order of no-display .desktop files 2013-03-28 Marco Trevisan (Treviño) BamfMatcher: make sure that all the no-display desktop files are last in our lists 2013-03-28 Marco Trevisan (Treviño) TestBamfMatcher: add no-display desktop file priority test 2013-03-28 Marco Trevisan (Treviño) BamfMatcherPrivate: add list to priv struct 2013-03-28 Marco Trevisan (Treviño) BamfMatcher: add No-Display desktop to a list and make sure they are kept at the end of our lists 2013-03-28 Marco Trevisan (Treviño) TestBamf: add a fake test-bamf-app program to our local PATH to make tests pass 2013-03-28 Marco Trevisan (Treviño) BamfMatcher: insert no-display .desktop files with lower priority 2013-03-28 Marco Trevisan (Treviño) debian/bamfdaemon.postinst: write it in multiline and add support for StartupWMClass And other properties such as NoDisplay and OnlyShowIn. Also rewritten the bamfdaemon.postinst to use a multi-line perl script for easier review. Fixes: https://bugs.launchpad.net/bugs/1161430. Approved by PS Jenkins bot, Loïc Minier, Brandon Schaefer. 2013-03-28 Marco Trevisan (Treviño) BamfMatcher: use bamf-2.index file 2013-03-28 Marco Trevisan (Treviño) Use g_strsplit to handle OnlyShowIn values 2013-03-28 Marco Trevisan (Treviño) debian/bamfdaemon.postinst: trim the parsed strings 2013-03-28 Marco Trevisan (Treviño) debian/bamfdaemon.postinst: indentation fix 2013-03-28 Marco Trevisan (Treviño) BamfMatcher: get the .desktop class from the index table and don't add ignored .desktop files 2013-03-28 Marco Trevisan (Treviño) debian/bamfdaemon.postinst: write it in multiline and add support for StartupWMClass And other properties such as NoDisplay and OnlyShowIn 2013-03-28 Marco Trevisan (Treviño) TestBamfMatcher: fix crashes caused by missing exec libbamf: use scanner-flags for introspection, fixes a compilation error. Approved by PS Jenkins bot, Brandon Schaefer. 2013-03-28 Marco Trevisan (Treviño) TestBamf: set PATH only after that we got the bus 2013-03-28 Marco Trevisan (Treviño) TestBamfDaemon: add fake binaries, and only use local path 2013-03-28 Marco Trevisan (Treviño) Removing unneeded flags 2013-03-28 Marco Trevisan (Treviño) TestBamfMatcher: fix crashes caused by missing exec 2013-03-28 Marco Trevisan (Treviño) libbamf: use scanner-flags for introspection 2013-03-07 Automatic PS uploader Releasing 0.4.0daily13.03.07-0ubuntu1 to ubuntu. Approved by PS Jenkins bot. 2013-03-07 Automatic PS uploader Releasing 0.4.0daily13.03.07-0ubuntu1, based on r523 2013-03-06 György Balló This change fixes the following two problems what I experienced while using BAMF on Arch Linux: 1. Fix desktop file table if XDG_CURRENT_DESKTOP environment variable is not available. Using the vanilla gnome-session without Ubuntu patches, the XDG_CURRENT_DESKTOP is not specified. In this case, all desktop files are ignored which contain the OnlyShowIn property. This isn't the expected behavior, because many GNOME desktop files are ignored in a GNOME session, e.g. nautilus, control center entries. To fix this issue, all desktop files should be added to the desktop file table if no XDG_CURRENT_DESKTOP specified. 2. Fix a critical warning if an empty Exec= line specified in a desktop file. Without this extra check, the following critical message displayed in this case (e.g. with the unity-scope-gdocs.desktop file): ** (bamfdaemon:20159): CRITICAL **: insert_data_into_tables: assertion `exec' failed. Approved by PS Jenkins bot, Marco Trevisan (Treviño). 2013-02-16 György Balló Fix memory leak 2012-12-04 György Balló Fix desktop file table if XDG_CURRENT_DESKTOP environment variable is not available. Fix also a critical varning if an empty Exec= line specified in a desktop file. 2013-02-06 Automatic PS uploader Releasing 0.4.0daily13.02.06-0ubuntu1 to ubuntu. Approved by Francis Ginther. 2013-02-06 Automatic PS uploader Releasing 0.4.0daily13.02.06-0ubuntu1, based on r521 2013-02-06 Marco Trevisan (Treviño) BamfView: use an idle to emit the active-changed signal to avoid to send the same event to a view. Fixes: https://bugs.launchpad.net/bugs/1115827. Approved by Brandon Schaefer. 2013-02-05 Marco Trevisan (Treviño) tests: update tests to check the active-changed results using the context iteration 2013-02-05 Marco Trevisan (Treviño) BamfApplication: use g_signal_handlers_disconnect_by_data 2013-02-05 Marco Trevisan (Treviño) BamfView: use an idle to emit the active-changed signal to avoid to send the same event to a view 2013-02-05 Marco Trevisan (Treviño) BamfLegacyScreen: don't initialize wnck in test-mode 2013-02-01 Marco Trevisan (Treviño) BamfLegacyWindow: use g_signal_handlers_disconnect_by_data 2013-02-01 Marco Trevisan (Treviño) BamfWindow: remove uneeded bamf_window_last_active value 2013-02-04 Alex Launi Sets is-foreground-tab in bamf_unity_webapps_tab_initialize_properties. Fixes: https://bugs.launchpad.net/bugs/1109198. Approved by Marco Trevisan (Treviño). 2013-02-04 Alex Launi Set is-foreground-tab property during property initialization 2013-02-01 Automatic PS uploader Releasing 0.4.0daily13.02.01-0ubuntu1 to ubuntu. Approved by . 2013-02-01 Automatic PS uploader Releasing 0.4.0daily13.02.01-0ubuntu1, based on r518 2013-01-29 Marco Trevisan (Treviño) BamfMatcher: ignore the javaws windows when setting the window hint. Fixes: https://bugs.launchpad.net/bugs/979752, https://bugs.launchpad.net/bugs/1098186, https://bugs.launchpad.net/bugs/1108380. Approved by Brandon Schaefer. 2013-01-29 Marco Trevisan (Treviño) BamfMatcher: don't abort if we can't monitor a directory, just log it 2013-01-29 Marco Trevisan (Treviño) BamfLegacyWindow: prevent a possible leak 2013-01-29 Marco Trevisan (Treviño) TestMatcher: added one more test to ensure javaws matching 2013-01-29 Marco Trevisan (Treviño) BamfMatcher: add bamf_matcher_is_valid_process_prefix to check for bad prefix process Now we ignore the bad process prefixes also when using the fallback process-name comparison. In this way the .desktop files that they may provide to load files are ignored. 2013-01-29 Marco Trevisan (Treviño) BamfLegacyWindowTest: implement the get_process_name function 2013-01-29 Marco Trevisan (Treviño) BamfLegacyWindow: add a function to fetch the process name 2013-01-29 Marco Trevisan (Treviño) TestMatcher: fix commandline, add missing spaces 2013-01-29 Marco Trevisan (Treviño) TestMatcher: added new trimming tests 2013-01-29 Marco Trevisan (Treviño) BamfMatcher: add support for Oracle webapps too 2013-01-29 Marco Trevisan (Treviño) TestMatcher: fix javawm class names 2013-01-29 Marco Trevisan (Treviño) Tests: add the missing icedtea-netx-javaws.desktop file 2013-01-29 Marco Trevisan (Treviño) TestMatcher: check that no hint is set for javaws windows 2013-01-29 Marco Trevisan (Treviño) BamfMatcher: ignore the javaws windows when setting the window hint 2013-01-11 Automatic PS uploader Releasing 0.4.0daily13.01.11-0ubuntu1 to ubuntu. Approved by . 2013-01-11 Automatic PS uploader Releasing 0.4.0daily13.01.11-0ubuntu1, based on r516 2013-01-10 Marco Trevisan (Treviño) BamfMatcher: Don't associate .desktopless applications with different exec string, fix JavaWS apps. Fixes: https://bugs.launchpad.net/bugs/979752. Approved by Brandon Schaefer. 2013-01-10 Marco Trevisan (Treviño) Fic compilation issue 2013-01-09 Marco Trevisan (Treviño) TestMatcher: Add javaws matching tests 2013-01-09 Marco Trevisan (Treviño) BamfMatcher: add JavaWS prefixes to BAD_PREFIXES list Fixes matching errors 2013-01-09 Marco Trevisan (Treviño) BamfMatcher: Don't associate .desktopless applications with different exec string 2013-01-09 Marco Trevisan (Treviño) BamfMatcher: some cleanup... 2013-01-09 Marco Trevisan (Treviño) BamfLegacyWindow: use g_signal_handlers_disconnect_by_data 2013-01-10 Marco Trevisan (Treviño) libbamf: use proper GIR dirs and build the gir1.2-bamf-0.2 package. Approved by Michael Terry. 2013-01-10 Marco Trevisan (Treviño) debian/control: add valac as build depends 2013-01-10 Marco Trevisan (Treviño) configure.ac: add more errors when checking build tools 2012-12-19 Marco Trevisan (Treviño) debian/control: remove unneded ${shlibs:Depends} 2012-12-19 Marco Trevisan (Treviño) Merge with trunk 2012-12-19 Marco Trevisan (Treviño) debian/changelog: update package name 2012-12-19 Marco Trevisan (Treviño) debian: move Bamf-*.gir to libbamf3-dev, rename gir package to gir1.2-bamf-3 Also, use the alphabetical order for the dependency list. 2012-12-19 Marco Trevisan (Treviño) libbamf: rename Bamf-0.2 gir to Bamf-3 2012-12-19 Marco Trevisan (Treviño) .bzrignore: update against new generated files 2012-12-19 Marco Trevisan (Treviño) libbamf: remove the unneeded gtk dependencies, use GIR variables 2012-12-19 Marco Trevisan (Treviño) debian: Add the gir1.2-bamf-0.2 package for gobject introspection 2012-12-19 Marco Trevisan (Treviño) libbamf: get the GIR datadir and typelib directories from pkg-config and use them to install 2013-01-09 Marco Trevisan (Treviño) BamfMatcher: improve the exec_string trimming code, revise the LO and GCC matching. Approved by Brandon Schaefer. 2013-01-09 Marco Trevisan (Treviño) Makefile.am.gtests: set the XDG_CURRENT_DESKTOP to unity for xless tests 2013-01-08 Marco Trevisan (Treviño) BamfMatcher: adding perl as bad prefix, improving style 2013-01-08 Marco Trevisan (Treviño) TestDaemon: added missing .desktop files to branch 2013-01-08 Marco Trevisan (Treviño) BamfMatcher: use a static array of strings to save good/bad prefixes 2013-01-08 Marco Trevisan (Treviño) TestMatcher: add ExecStringTrimming test 2013-01-08 Marco Trevisan (Treviño) BamfMatcher: improve the exec_string trimming code, refactor the LO and GCC matching 2013-01-08 Marco Trevisan (Treviño) TestMatcher: Add gnome-control-center matching tests 2013-01-08 Marco Trevisan (Treviño) BamfLegacyWindow: fix docs typos 2013-01-07 Marco Trevisan (Treviño) BamfLegacyScreen: use a simpler stack comparison function 2012-12-18 Marco Trevisan (Treviño) BamfMatcher: more cleanups... 2012-12-19 Marco Trevisan (Treviño) libbamf: bump the SONAME value and remove the unneeded libwnck dependencies. Approved by Michael Terry, PS Jenkins bot. 2012-12-19 Marco Trevisan (Treviño) Updating .bzrignore 2012-12-19 Marco Trevisan (Treviño) libbamf: remove the libbamf.pc.in file 2012-12-19 Marco Trevisan (Treviño) debian/control: put back the trailing comma 2012-12-19 Marco Trevisan (Treviño) debian: remove the unneded dependencies, rename libbamf3-0.* files 2012-12-19 Marco Trevisan (Treviño) libbamf: use 1.0.0 as SONAME 2012-12-19 Marco Trevisan (Treviño) debian: remove the unneded library wnck dependencies and update the changelog 2012-12-19 Marco Trevisan (Treviño) Libbamf does not depend on libwnck directly... 2012-12-19 Marco Trevisan (Treviño) libbamf: increase the SONAME version 2012-12-19 Andrea Azzarone Make BamfWindow and BamfTab mockable. Approved by Marco Trevisan (Treviño). 2012-12-19 Andrea Azzarone Add padding. 2012-12-19 Andrea Azzarone Make bamf-tab/window mockable. 2012-12-19 Marco Trevisan (Treviño) BamfMatcher: use a GList to handle known pids. Approved by Brandon Schaefer, PS Jenkins bot. 2012-12-18 Marco Trevisan (Treviño) BamfMatcher: use a GList to handle known pids 2012-12-18 Marco Trevisan (Treviño) BamfMatcher: remove the duplicated code to fetch a window exec string. Approved by Brandon Schaefer, PS Jenkins bot. 2012-12-18 Marco Trevisan (Treviño) BamfMatcher: remove the duplicated code to fetch a window exec string 2012-12-18 Marco Trevisan (Treviño) Merging with lp:~3v1n0/bamf/remove-indicators (and trunk) 2012-12-17 Marco Trevisan (Treviño) BamfMatcher: remove trailing spaces 2012-12-17 Marco Trevisan (Treviño) BamfLegacyWindow: use guint for PID 2012-12-17 Marco Trevisan (Treviño) BamfMatcher: also match javaws as bad prefix 2012-12-18 Marco Trevisan (Treviño) Bamf: removing the indicators related code (dead). Approved by Brandon Schaefer. 2012-12-18 Marco Trevisan (Treviño) Bamf: removing the indicators related code (dead) 2012-12-17 Francis Ginther Add code coverage reporting with coverage-html and coverage-gcovr targets. Coverage reporting can be enabled with --enable-gcov. Approved by Marco Trevisan (Treviño), Allan LeSage. 2012-12-13 Francis Ginther Fixed building for non-scrdir builds and incorrect LD flags. 2012-12-06 Francis Ginther Adding code coverage reporting with coverage-html and coverage-xml targets. Coverage reporting can be enabled with --enable-gcov. 2012-12-10 Rico Tzschichholz libbamf/bamfapplication: Fix annotation for get_xids. Approved by Michael Terry. 2012-12-06 Rico Tzschichholz libbamf/bamfapplication: Fix annotation for get_xids 2012-12-06 Francis Ginther Fix test failure caused when xvfb exits before script has a chance to kill it on script exit The xvfb process may or may not be present when the test script exits. Allow this with the addition of "||true". Fixes: https://bugs.launchpad.net/bugs/1079329. Approved by Marco Trevisan (Treviño). 2012-12-05 Francis Ginther Fix test failure caused when xvfb exits before script has a chance to kill it on script exit The xvfb process may or may not be present when the test script exits. Allow this with the addition of "||true". 2012-12-06 Didier Roche releasing version 0.4.0daily12.12.05-0ubuntu2 2012-12-06 Didier Roche Remove a wrong build-dep 2012-12-05 Didier Roche Remove wrong build-dep from -dbg on libbamf0 2012-12-05 Didier Roche Releasing 0.4.0daily12.12.05-0ubuntu1 to ubuntu 2012-12-05 Automatic PS uploader Releasing 0.4.0daily12.12.05-0ubuntu1, based on r502 2012-11-19 Marco Trevisan (Treviño) Autconf, debian: remove the legacy gtk-2 support and factorize the test building code. Approved by Michael Terry. 2012-11-19 Marco Trevisan (Treviño) Autoconf: point to correct Makefile in testing. 2012-11-19 Marco Trevisan (Treviño) debian/rules: demoved the unneeded overrides 2012-11-19 Marco Trevisan (Treviño) debian: update glib2 dependency and changelog 2012-11-15 Marco Trevisan (Treviño) debian: update changelog 2012-11-15 Marco Trevisan (Treviño) Autoconf: remove the Makefile code duplication for testing 2012-11-15 Marco Trevisan (Treviño) debian: remove the gtk2 packages, just do one build. 2012-11-14 Marco Trevisan (Treviño) Autoconf: globally define the libbamf library version 2012-11-14 Marco Trevisan (Treviño) Bamf: remove the legacy gtk-2 support 2012-11-15 Marco Trevisan (Treviño) libbamf, BamfMatcher: avoid to return the same app twice in bamf_matcher_get_applications. Fixes: https://bugs.launchpad.net/bugs/1078448. Approved by Łukasz Zemczak. 2012-11-13 Marco Trevisan (Treviño) libbamf, BamfMatcher: avoid to return the same app twice in bamf_matcher_get_applications 2012-11-15 Marco Trevisan (Treviño) Bump revision to 0.4.0. Approved by Michael Terry. 2012-11-14 Marco Trevisan (Treviño) debian: updating symbols to 0.4.0 2012-11-14 Marco Trevisan (Treviño) Merging with Terry's branch again 2012-11-14 Marco Trevisan (Treviño) Merging with lp:~mterry/bamf/c4 2012-11-14 Marco Trevisan (Treviño) Move to Bamf 0.4 2012-11-15 Michael Terry Use -c4 for dpkg-gensymbols to catch when we add or remove symbols from the library. Approved by Marco Trevisan (Treviño). 2012-11-14 Michael Terry merge in didrocks's bootstrap branch 2012-11-14 Michael Terry use dpkg-gensymbols -c4 2012-11-15 Didier Roche Bootstrap for the daily build system. No bug to list on that one. Approved by . 2012-11-14 Didier Roche bootstrap for daily build with the correct revision, no bug to list 2012-11-12 Rico Tzschichholz tests: Don't call g_type_init while building against glib >= 2.35. Approved by Marco Trevisan (Treviño). 2012-10-27 Rico Tzschichholz tests: Don't call g_type_init while building against glib >= 2.35 2012-11-12 Rico Tzschichholz libbamf: add bamf_view_is_user_visible () This makes the gir/vala api nicer and avoids a conlict with the property. Mark bamf_view_user_visible as deprecated using glib 2.32 macro. Approved by Marco Trevisan (Treviño). 2012-10-27 Rico Tzschichholz libbamf: update version-annotations to target 0.4.0 2012-10-09 Rico Tzschichholz libbamf, tests: replace deprecated calls of bamf_view_user_visible () 2012-10-08 Rico Tzschichholz bamf-view: add bamf_view_is_user_visible () This makes the gir/vala api nicer and avoids a conlict with the property. Mark bamf_view_user_visible as deprecated using glib 2.32 macro 2012-11-08 Michael Terry Switch debian/ to debhelper 9 and other small build modernizations. Approved by Didier Roche, Stephen M. Webb. 2012-11-07 Michael Terry switch to dh9 2012-11-07 Didier Roche Bring debian/ packaging inline, build with dh-autoregen, and update the debian symbols files.. Approved by Francis Ginther, Marco Trevisan (Treviño), Didier Roche. 2012-11-05 Michael Terry move debian/ packaging inline 2012-10-17 Didier Roche releasing version 0.3.4-0ubuntu1 2012-10-17 Didier Roche don't forget the arg 2012-10-17 Didier Roche * debian/bamfdaemon.postinst: - Fix bamf.index perl script generation to fix UOA g-c-c panel associated with empathy. (LP: #1045223) 2012-10-17 Didier Roche modify changelog 2012-10-12 Timo Jyrinki * New upstream release. - BamfFactory: don't use the secondary matching method for views with valid .desktop file (LP: #1026426) (already cherry-picked to Ubuntu) - Autoconf: Make libunity-webapps an optional dependency - Libbamf: Some signal, type and annotation fixes - libbamf: gir-annotion fixes and make gi-scanner verbose - Autoconf: Exclude generated sources from tarball and fix "make distcheck". - BamfMatcher: add support for libreoffice Base, and libreoffice matching tests (LP: #1063862) 2012-10-12 Timo Jyrinki Import upstream version 0.3.4 2012-10-12 Timo Jyrinki Release 0.3.4 2012-10-04 Didier Roche releasing version 0.3.2-0ubuntu1 2012-10-04 Timo Jyrinki Cherry-pick LibreOffice fix (LP: #1026426) 2012-10-04 Timo Jyrinki Cherry-pick LibreOffice fix (LP: #1026426) 2012-10-04 Didier Roche let's target -proposed 2012-10-04 Didier Roche releasing version 0.3.2-0ubuntu1 2012-10-01 Łukasz 'sil2100' Zemczak * New upstream release. - bamfdaemon crashes in bamf_application_get_supported_mime_types (LP: #1058260) - Webapps close prematurely (LP: #1051042) - Broken UI and no window management (LP: #1053288) 2012-10-01 Łukasz 'sil2100' Zemczak Import upstream version 0.3.2 2012-09-19 Ken VanDine releasing version 0.3.0-0ubuntu2 2012-09-14 Ken VanDine rebuild for latest libunity-webapps 2012-08-31 Sebastien Bacher releasing version 0.3.0-0ubuntu1 2012-08-31 Sebastien Bacher * Note that while technically that update breaks compatibility by dropping some public functions the corresponding code never worked and it has been verified those were not used by any rdepends. * debian/libbamf3-0.symbols: - updated as well 2012-08-31 Sebastien Bacher [ Łukasz 'sil2100' Zemczak ] * New upstream release. - added webapps support * debian/libbamf0.symbols: - updated symbol file, removed some broken methods 2012-08-30 Łukasz 'sil2100' Zemczak * debian/libbamf0.symbols: - updated symbol file, removed some broken methods 2012-08-22 Łukasz 'sil2100' Zemczak * debian/control: - Build-Depends on libunity-webapps-dev to prepare the landing of the branch using it * New upstream release. - added webapps support 2012-08-22 Łukasz 'sil2100' Zemczak Import upstream version 0.3.0 2012-08-22 Ken VanDine build depend on libunity-webapps-dev >= 2.0.1 2012-08-22 Sebastien Bacher debian/control: Build-Depends on libunity-webapps-dev to prepare the landing of the branch using it 2012-08-10 Didier Roche releasing version 0.2.122-0ubuntu1 2012-08-10 Łukasz 'sil2100' Zemczak * New upstream release. - Type mismatch in libbamf bamf_control_register_application_for_pid() and dbus interface (LP: #1021143) - running applications without an icon use a blank icon (LP: #886778) 2012-08-10 Łukasz 'sil2100' Zemczak Import upstream version 0.2.122 2012-07-10 Didier Roche releasing version 0.2.120-0ubuntu1 2012-07-05 Łukasz 'sil2100' Zemczak Changed one changelog entry to be more 'correct': removed symbols that were wrongly exported upstream before (private symbols) 2012-07-04 Łukasz 'sil2100' Zemczak * debian/libbamf0.symbols, debian/libbamf3-0.symbols: - removed symbols that are no longer exported 2012-07-04 Łukasz 'sil2100' Zemczak * New upstream release. - Started applications pinned to the launcher are not set as running (LP: #976642) - sometimes icons get dropped from the launcher when they should not (LP: #925421) 2012-07-04 Łukasz 'sil2100' Zemczak Import upstream version 0.2.120 2012-06-25 Didier Roche releasing version 0.2.118-1ubuntu1 2012-06-25 Didier Roche * debian/control: - change packaging location to canonical branch (lp:ubuntu/bamf) 2012-06-25 Didier Roche * debian/*symbols: - add new private symbol (will not be exported after next release) 2012-06-25 Didier Roche * Sync from debian. No more difference. * Cherry-pick from upstream: - Started applications pinned to the launcher are not set as running (LP: #976642) - sometimes icons get dropped from the launcher when they should not (LP: #925421) - multiple instances or double icons of application detected on bamfdaemon respawn (LP: #928912) - unity confused with chrome/chromium web apps (LP: #692462) - BamfView's dispose() method doesn't invoke the superclass' dispose() (LP: #986888) * debian/control: - remove Multi-Arch: same for the -dbg package (Closes: #669980, #658057) * New upstream release. - Unity crashed in bamf_application_on_window_removed (LP: #1000577) - Locked smuxi launcher icon does not indicate smuxi running status (LP: #999820) - No launcher icon or Alt+Tab entry for Gimp windows (LP: #995916) - the RunningApplicationsChanged signal is no longer emitted when an application is closed since r460 (LP: #989551) * New upstream release. (0.2.116) 2012-06-20 Łukasz 'sil2100' Zemczak sometimes icons get dropped from the launcher when they should not (LP: #925421) 2012-06-20 Łukasz 'sil2100' Zemczak * Cherry-pick from upstream: - Started applications pinned to the launcher are not set as running (LP: #976642) 2012-05-24 Sebastien Bacher releasing version 0.2.118-0ubuntu0.1 2012-06-22 Didier Roche dummy update for merging 2012-06-01 Didier Roche releasing version 0.2.118-1 2012-06-01 Didier Roche - ensure the gtk2/gtk3 version doesn't have the same description * debian/sources/format: - added to specify we use format 1.0 2012-06-01 Didier Roche * debian/rules: - add hardening flags (thanks Andrea) 2012-06-01 Didier Roche - remove build-dep only used for unit tests - replace the gtk2 variant of the wnck introspection gir package with gtk3 one 2012-06-01 Didier Roche * debian/*.symbols: - adding some PRIVATE symbols to make lintian happy. We saw that bamf is exporting by error some of its private symbols. This will be fixed in next released (and so the symbols will be removed from the .symbols files) 2012-06-01 Didier Roche * Backport latest release to debian * debian/control: - bump Standards-Version to latest * Initial upload to Debian. Package grabbed from Ubuntu, we'll keep this package in sync within the two distributions. * debian/control: - removed gir's package for now, still not building correctly. * debian/control: - changed Maintainer accordingly. - added myself into uploaders. 2012-05-24 Sebastien Bacher releasing version 0.2.118-0ubuntu1 2012-05-24 Sebastien Bacher [ Didier Roche ] * New upstream release. (0.2.116) [ Alan Pope ] * New upstream release. - Unity crashed in bamf_application_on_window_removed (LP: #1000577) - Locked smuxi launcher icon does not indicate smuxi running status (LP: #999820) - No launcher icon or Alt+Tab entry for Gimp windows (LP: #995916) - the RunningApplicationsChanged signal is no longer emitted when an application is closed since r460 (LP: #989551) 2012-05-23 Alan Pope * New upstream release. (0.2.116) * New upstream release. - Unity crashed in bamf_application_on_window_removed (LP: #1000577) - Locked smuxi launcher icon does not indicate smuxi running status (LP: #999820) - No launcher icon or Alt+Tab entry for Gimp windows (LP: #995916) - the RunningApplicationsChanged signal is no longer emitted when an application is closed since r460 (LP: #989551) 2012-05-23 Alan Pope Import upstream version 0.2.118 2012-05-23 Alan Pope Releasing 0.2.118 2012-04-27 Didier Roche - multiple instances or double icons of application detected on bamfdaemon respawn (LP: #928912) - unity confused with chrome/chromium web apps (LP: #692462) - BamfView's dispose() method doesn't invoke the superclass' dispose() (LP: #986888) 2012-04-27 Didier Roche * New upstream release. * debian/control: - remove Multi-Arch: same for the -dbg package (Closes: #669980, #658057) 2012-04-27 Didier Roche Import upstream version 0.2.116 2012-03-23 Didier Roche releasing version 0.2.114-0ubuntu1 2012-03-23 Didier Roche invalid valgrind read errors (LP: #929468) 2012-03-23 Didier Roche New upstream release. 2012-03-23 Didier Roche Import upstream version 0.2.114 2012-03-12 Didier Roche releasing version 0.2.112-0ubuntu1 2012-03-12 Didier Roche - bamf matcher messes up refcounting on views (LP: #942070) - Chromium is running, but not showing in launcher or alt-tab. (LP: #918474) - libbamf leaks memory on view dispose (LP: #942148) - Coverity PW.PARAMETER_HIDDEN - CID 10449 (LP: #937398) - Coverity UNINIT - CID 10451 (LP: #937402) 2012-03-12 Didier Roche * debian/libbamf0.symbols, debian/libbamf3-0.symbols: - update symbols for new API 2012-03-12 Didier Roche New upstream release. 2012-03-12 Didier Roche Import upstream version 0.2.112 2012-02-17 Didier Roche releasing version 0.2.110-0ubuntu1 2012-02-17 Didier Roche - BAMF does not pass make check (LP: #897148) - BAMF requires a headless testing target (LP: #897150) - Clicking Nautilus launcher icon fails to open a Nautilus file explorer window when copying a file and all other Nautilus windows are closed / bamf should skip the taskbar (LP: #784804) 2012-02-17 Didier Roche * debian/libbamf0.symbols, debian/libbamf3-0.symbols: - updated symbols 2012-02-17 Didier Roche New upstream release. 2012-02-17 Didier Roche Import upstream version 0.2.110 2012-02-03 Didier Roche releasing version 0.2.108-0ubuntu2 2012-02-03 Didier Roche * remove -Werror for now as there is new glib deprecation making FTBFS. * debian/source/ - remove, doesn't play well with merge-upstream workflow 2012-02-03 Didier Roche releasing version 0.2.108-0ubuntu1 2012-02-03 Didier Roche - BAMF does not pass make check (LP: #897148) - BAMF requires a headless testing target (LP: #897150) - Clicking Nautilus launcher icon fails to open a Nautilus file explorer window when copying a file and all other Nautilus windows are closed / bamf should skip the taskbar (LP: #784804) 2012-02-03 Didier Roche * debian/libbamf0.symbols, debian/libbamf3-0.symbols: - updated symbols 2012-02-03 Didier Roche * debian/libbamf0.symbols: - updated 2012-02-03 Didier Roche New upstream release. 2012-02-03 Didier Roche Import upstream version 0.2.108 2012-01-12 Didier Roche update changelog 2012-01-12 Didier Roche releasing version 0.2.106-0ubuntu1 2012-01-12 Didier Roche * debian/control: - bump libglib2.0-dev to 2.28 2012-01-12 Didier Roche New upstream release. 2012-01-12 Didier Roche Import upstream version 0.2.106 2011-11-28 Didier Roche add more build-deps 2011-11-28 Didier Roche * debian/control, debian/rules: - enable headless tests build 2011-09-26 Didier Roche releasing version 0.2.104-0ubuntu1 2011-09-26 Didier Roche - Hopefully really fix unity confused with chrome (not chromium) web apps (LP: #692462) - Fix to build with gtk2 version 2011-09-26 Didier Roche Import upstream version 0.2.104 2011-09-26 Didier Roche * New upstream release. - Hopefully really fix unity confused with chrome web apps (LP: #692462) 2011-09-26 Didier Roche Import upstream version 0.2.102 2011-09-22 Didier Roche releasing version 0.2.100-0ubuntu1 2011-09-22 Didier Roche New upstream release. 2011-09-22 Didier Roche Import upstream version 0.2.100 2011-09-22 Didier Roche release 0.2.100 2011-09-15 Didier Roche releasing version 0.2.98-0ubuntu2 2011-09-15 Didier Roche * Cherry-pick a crasher fix: - bamfdaemon crashed with SIGSEGV in sn_xcb_display_new() 2011-09-08 Didier Roche releasing version 0.2.98-0ubuntu1 2011-09-08 Didier Roche * debian/control: - update Standards-Version 2011-09-08 Didier Roche Bamf doesn't recognize just installed applications (LP: #676593) 2011-09-08 Didier Roche New upstream release. 2011-09-08 Didier Roche Import upstream version 0.2.98 2011-08-25 Sebastien Bacher releasing version 0.2.96-0ubuntu1 2011-08-25 Sebastien Bacher New upstream release. 2011-08-25 Sebastien Bacher Import upstream version 0.2.96 2011-08-04 Didier Roche releasing version 0.2.94-0ubuntu1 2011-08-04 Didier Roche * debian/bamfdaemon.install: - do not install the gio module as it's not built anymore 2011-08-04 Didier Roche * debian/rules: - the new tests depends on a X server, desactivate them when building on buildd 2011-08-04 Didier Roche * New upstream release: - no more dependency on the gio ubuntu patch, use the upstream system now (LP: #687683) 2011-08-04 Didier Roche Import upstream version 0.2.94 2011-08-04 Didier Roche release 0.2.94 2011-06-17 Michael Terry add missing libbamf3 debian files 2011-06-17 Michael Terry set source format 2011-06-17 Michael Terry * debian/control, debian/rules: - Add libbamf3-0 and libbamf3-dev packages for GTK+ 3 2011-06-17 Michael Terry merge new release 2011-06-17 Michael Terry Import upstream version 0.2.92 2011-04-27 Didier Roche proposed is the target 2011-04-27 Didier Roche releasing version 0.2.90-0ubuntu3 2011-04-27 Didier Roche * Cherry-pick from upstream: - System Testing and Printers don't display proper menus when launched by command line (LP: #717134) - Unity Min,Max,Close buttons not available in Libreoffice when opened by double-clicking a file (LP: #728927) 2011-04-20 Didier Roche releasing version 0.2.90-0ubuntu2 2011-04-20 Didier Roche * Cherry-pick from upstream: - Thunderbird won't stay in launcher and no quicklist (LP: #765736) 2011-04-19 Didier Roche releasing version 0.2.90-0ubuntu1 2011-04-19 Didier Roche - compiz assert failure: *** glibc detected *** compiz: double free or corruption (out): 0x0a1c5a38 *** (LP: #761372) - "Authenticate" window shows in launcher as "Polkit-gnome-authentication- agent-1" (LP: #740844) 2011-04-19 Didier Roche New upstream release. 2011-04-19 Didier Roche Import upstream version 0.2.90 2011-04-15 Didier Roche releasing version 0.2.86-0ubuntu3 2011-04-15 Didier Roche Cherry-pick a crash fix in unity with double free corruption (LP: #761372) 2011-04-12 Sebastien Bacher releasing version 0.2.86-0ubuntu2 2011-04-12 Sebastien Bacher Trunk commit r358, really fixes the crash bug listed before (lp: #754225) 2011-04-11 Didier Roche releasing version 0.2.86-0ubuntu1 2011-04-11 Didier Roche * New upstream release. - bamfdaemon crashed with SIGABRT in dbus_g_connection_register_g_object() (LP: #752137) - bamfdaemon crashed with SIGABRT in dbus_g_connection_register_g_object() (LP: #754225) 2011-04-11 Didier Roche Import upstream version 0.2.86 2011-04-07 Steve Langasek releasing version 0.2.84-0ubuntu2 2011-04-07 Steve Langasek Move the giomodule DSO back to /usr/lib/gio/modules, because something we haven't identified yet refuses to see it when it's installed to the multiarch path. LP: #751025 2011-04-07 Didier Roche releasing version 0.2.84-0ubuntu1 2011-04-07 Didier Roche - unity-panel-service crashed with SIGSEGV in bamf_factory_view_for_path() (LP: #717684) - bamfdaemon crashed with SIGABRT in dbus_g_connection_register_g_object() (LP: #739218) - compiz crashed with SIGSEGV in g_utf8_validate() (LP: #736792) 2011-04-07 Didier Roche New upstream release. 2011-04-07 Didier Roche Import upstream version 0.2.84 2011-04-01 Didier Roche releasing version 0.2.82-0ubuntu1 2011-04-01 Didier Roche - bamfdaemon crashed with SIGSEGV in XInternAtom() (LP: #743407) - catch more cases for 'Keep in Launcher' by recognizing StatupWMClass from .desktop file (LP: #693231) 2011-04-01 Didier Roche New upstream release. 2011-04-01 Didier Roche Import upstream version 0.2.82 2011-03-29 Steve Langasek * Fix a FTBFS with current libglib2.0 due to the giomodules path changing for multiarch. * As long as we're in here, multiarch the whole package; bamf has no reverse-depends, so there's no risk of causing other build failures, and moving the giomodules takes us halfway there anyway. 2011-03-17 Didier Roche releasing version 0.2.80-0ubuntu1 2011-03-17 Didier Roche * New upstream release. - 'Keep in launcher' item missing for some applications (LP: #657771) - can't pin KTouch to the launcher (LP: #693755) 2011-03-17 Didier Roche Import upstream version 0.2.80 2011-02-10 Didier Roche releasing version 0.2.78-0ubuntu1 2011-02-10 Didier Roche * New upstream release: - adapt bamf to LibreOffice (LP: #705461) 2011-02-10 Didier Roche Import upstream version 0.2.78 2011-01-27 Didier Roche releasing version 0.2.76-0ubuntu1 2011-01-27 Didier Roche add a new signal to detect tab changes (LP: #691651) 2011-01-27 Didier Roche New upstream release. 2011-01-27 Didier Roche Import upstream version 0.2.76 2011-01-20 Didier Roche releasing version 0.2.74-0ubuntu1 2011-01-20 Didier Roche - Set the default application icon when the application desktop file has no icon= key. It was appearing fully black. (LP: #703521) * debian/control: - remove vala build-dep, not needed anymore 2011-01-20 Didier Roche New upstream release. 2011-01-20 Didier Roche Import upstream version 0.2.74 2011-01-14 Didier Roche releasing version 0.2.72-0ubuntu1 2011-01-14 Didier Roche New upstream release. 2011-01-14 Didier Roche Import upstream version 0.2.72 2011-01-14 Didier Roche releasing version 0.2.70-0ubuntu1 2011-01-14 Didier Roche * New upstream release. * debian/control: bamf dbus protocol changed. Breaks: on old unity 2011-01-14 Didier Roche Import upstream version 0.2.70 2010-12-17 Sebastien Bacher releasing version 0.2.68-0ubuntu1 2010-12-17 Sebastien Bacher New upstream release. 2010-12-17 Sebastien Bacher Import upstream version 0.2.68 2010-12-13 Didier Roche * debian/control: - add Vcs-Bzr tag 2010-12-09 Didier Roche releasing version 0.2.66-0ubuntu1 2010-12-09 Didier Roche unity-panel-service crashed with SIGSEGV in free() (LP: #677580) 2010-12-09 Didier Roche - Fix the Ubuntu Starter Edition bug (LP: #683623) - check that desktop file is currently supported before creating the favorite (LP: #682345) 2010-12-09 Didier Roche New upstream release. 2010-12-09 Didier Roche Import upstream version 0.2.66 2010-11-30 Didier Roche releasing version 0.2.64-0ubuntu1 2010-11-30 Didier Roche New upstream release. 2010-11-30 Didier Roche Import upstream version 0.2.64 2010-11-18 Didier Roche releasing version 0.2.62-0ubuntu1 2010-11-18 Didier Roche New upstream release. 2010-11-18 Didier Roche Import upstream version 0.2.62 2010-11-11 Didier Roche releasing version 0.2.60-0ubuntu1 2010-11-11 Didier Roche new upstream release 2010-11-11 Didier Roche update symbols 2010-11-11 Didier Roche New upstream release. 2010-11-11 Didier Roche Import upstream version 0.2.60 2010-11-05 Didier Roche * debian/libbamf0.symbols: - add the new symbols 2010-11-05 Didier Roche fix DSO linking 2010-11-05 Didier Roche merge back from upstream to build new unity 2010-09-30 Didier Roche releasing version 0.2.58-0ubuntu2 2010-09-30 Didier Roche Fix tons of accuracy matching issues using the gio module (LP: #645849, #630066) 2010-09-27 Didier Roche releasing version 0.2.58-0ubuntu1 2010-09-27 Didier Roche * New upstream release: - Fix Nautilus' "File Operation" dialog gets stuck and prevents opening new Nautilus windows (LP: #647979) - Fix bamfdaemon crashed with SIGSEGV in g_str_hash() (LP: #638705) 2010-09-27 Didier Roche Import upstream version 0.2.58 2010-09-22 Didier Roche * debian/libbamf0.symbols: - update to latest version 2010-09-22 Didier Roche releasing version 0.2.54-0ubuntu1 2010-09-22 Didier Roche cherry pick some patches from upstream too for more fixes in special launchers (LP: #622146) 2010-09-22 Didier Roche third cherry pick 2010-09-22 Didier Roche second cherry pick 2010-09-22 Didier Roche first cherry pick 2010-09-22 Didier Roche New upstream release. 2010-09-22 Didier Roche Import upstream version 0.2.54 2010-09-17 Didier Roche Take previous distro inline patch with next release (LP: #641229) 2010-09-17 Didier Roche releasing version 0.2.52-0ubuntu1 2010-09-17 Didier Roche * New upstream release: - Take previous distro inline patch with next release 2010-09-17 Didier Roche Import upstream version 0.2.52 2010-09-15 Ken VanDine releasing version 0.2.50-0ubuntu1 2010-09-15 Ken VanDine Import upstream version 0.2.50 2010-09-14 Didier Roche releasing version 0.2.48-0ubuntu1 2010-09-14 Didier Roche update debian/libbamf0.symbols 2010-09-14 Didier Roche * New upstream release: - Dropbox 0.8.90 build shows in the launcher (LP: #610226) 2010-09-14 Didier Roche New upstream release. 2010-09-14 Didier Roche Import upstream version 0.2.48 2010-09-09 Didier Roche releasing version 0.2.46-0ubuntu1 2010-09-09 Didier Roche Handle non system launchers (LP: #622146) 2010-09-09 Didier Roche New upstream release. 2010-09-09 Didier Roche Import upstream version 0.2.46 2010-08-19 Sebastien Bacher releasing version 0.2.44-0ubuntu1 2010-08-19 Sebastien Bacher * New upstream release: - Fix potential NULL deref when XDG_DATA_DIRS is not set (lp: #602519) * debian/control: - updated for the new vala versioning * debian/libbamf0.symbols: - new version update 2010-08-19 Sebastien Bacher Import upstream version 0.2.44 2010-08-19 Sebastien Bacher releasing version 0.2.42-0ubuntu2 2010-08-13 Didier Roche releasing version 0.2.42-0ubuntu1 2010-08-13 Didier Roche * New upstream release. - remove gir-repository-dev from build-dep 2010-08-13 Didier Roche New upstream release. 2010-08-13 Didier Roche Import upstream version 0.2.42 2010-08-11 Didier Roche * debian/control: - bumping Standards-Version to latest 2010-08-11 Didier Roche * debian/rules: - enjoying and running testsuite during build (LP: #586340) 2010-08-02 Didier Roche releasing version 0.2.40-0ubuntu1 2010-08-02 Didier Roche New upstream release. 2010-08-02 Didier Roche Import upstream version 0.2.40 2010-07-22 Didier Roche releasing version 0.2.38-0ubuntu1 2010-07-22 Didier Roche New upstream release. 2010-07-22 Didier Roche Import upstream version 0.2.38 2010-07-22 Didier Roche New upstream release. 2010-07-22 Didier Roche Import upstream version 0.2.37 2010-07-16 Didier Roche releasing version 0.2.36-0ubuntu1 2010-07-16 Didier Roche * debian/libbamf0.symbols: - update to latest 2010-07-16 Didier Roche New upstream release. 2010-07-16 Didier Roche Import upstream version 0.2.36 2010-07-12 Didier Roche releasing version 0.2.34-0ubuntu1 2010-07-12 Didier Roche - Hangs when nautilus device detected dialog are displayed (LP: #601017) - Netbeans does not show in Unity when open (LP: #598083) - The launcher doesn't list some running softwares (LP: #601082) 2010-07-12 Didier Roche New upstream release. 2010-07-12 Didier Roche Import upstream version 0.2.34 2010-06-24 Didier Roche releasing version 0.2.32-0ubuntu1 2010-06-24 Didier Roche * New upstream release. - fix bad matchin on OOo (LP: #595583) - fix crash in bamf_matcher_possible_applications_for_window (LP: #597986) - fix exaile icon not showing in launcher (LP: #593470) 2010-06-24 Didier Roche Import upstream version 0.2.32 2010-06-17 Didier Roche releasing version 0.2.30-0ubuntu1 2010-06-17 Didier Roche * New upstream release: - fix KDE applications not showing up in the Unity Launcher (LP: #592502) 2010-06-17 Didier Roche New upstream release. 2010-06-17 Didier Roche New upstream release. 2010-06-17 Didier Roche Import upstream version 0.2.30 2010-06-14 Didier Roche * debian/libbamf0.symbols: - adding new symbols 2010-06-10 Didier Roche releasing version 0.2.28-0ubuntu1 2010-06-10 Didier Roche New upstream release. 2010-06-10 Didier Roche Import upstream version 0.2.28 2010-06-07 Didier Roche dummy commit for making hudson happy 2010-06-07 Didier Roche releasing version 0.2.26-0ubuntu2 2010-06-07 Didier Roche * debian/libbamf-dev.install: - don't try to install a vapi file right now 2010-06-07 Didier Roche releasing version 0.2.26-0ubuntu1 2010-06-07 Didier Roche * debian/libbamf-dev.install: - install vapi files 2010-06-07 Didier Roche New upstream release. 2010-06-07 Didier Roche Import upstream version 0.2.26 2010-06-07 Didier Roche * debian/watch: - use https 2010-06-03 Didier Roche fix version 2010-06-03 Didier Roche fix DEB_CONFIGURE_EXTRA_FLAGS 2010-06-03 Didier Roche * debian/rules: - fix rm *{,l}a files 2010-06-03 Didier Roche * debian/control, debian/rules: - build the doc by default 2010-06-03 Didier Roche remove provides/replaces/conflicts: doesn't work without transitional package and autopurge do the work 2010-06-03 Didier Roche * debian/control: - replaces wncksync 2010-06-03 Didier Roche fix typo in control 2010-06-03 Didier Roche * debian/libbamf0.symbols: - updated 2010-06-02 Didier Roche * debian/control, debian/libbamf-doc.install: - add libbamf-doc package 2010-05-27 Didier Roche releasing version 0.2.24-0ubuntu1 2010-05-27 Didier Roche Import upstream version 0.2.24 2010-05-27 Didier Roche releasing version 0.2.22-0ubuntu1 2010-05-27 Didier Roche remove chromium plugin copyright as not shipped for now 2010-05-27 Didier Roche use bamf-dbg as debug package 2010-05-27 Didier Roche use libbamf0-dbg debug file 2010-05-27 Didier Roche disabling gobject-introspection 2010-05-26 Didier Roche temporary disabling gir building due to bug: https://bugzilla.gnome.org/show_bug.cgi?id=619703 2010-05-25 Didier Roche add bugnumber 2010-05-25 Didier Roche add gir1.0-wnck-1.0 2010-05-25 Didier Roche readd typelib as needed by dh_gir 2010-05-25 Didier Roche fix spaces instead of tabs 2010-05-25 Didier Roche add gir goodness 2010-05-25 Didier Roche First merge-upstream usage 2010-05-25 Didier Roche Import upstream version 0.2.22 2010-05-25 Didier Roche update copyright 2010-05-25 Didier Roche add symbol file and some fixes to postinst/postrm 2010-05-25 Didier Roche libbamf0 is the soname finally 2010-05-25 Didier Roche first packaging attempt 2010-05-25 Didier Roche adjust soname 2010-05-25 Didier Roche adjust soname 2012-10-17 Marco Trevisan (Treviño) BamfMatcher: always associate children windows to the parent application. Approved by Brandon Schaefer. 2012-10-17 Marco Trevisan (Treviño) BamfMatcher: fix indentation 2012-10-16 Marco Trevisan (Treviño) TestMatcher: check if a window with a transient set, is correctly matched 2012-10-16 Marco Trevisan (Treviño) BamfLegacyWindowTest: implement the get_transient method 2012-10-16 Marco Trevisan (Treviño) BamfLegacyWindow: allow to override the get_transient function 2012-10-16 Marco Trevisan (Treviño) BamfMatcher: use a better code path for transient windows, some code cleanup 2012-10-16 Marco Trevisan (Treviño) BamfView: check if the path has been set before checking for the object path 2012-10-10 Marco Trevisan (Treviño) BamfMatcher: add support for libreoffice Base, and libreoffice matching tests. Fixes: https://bugs.launchpad.net/bugs/1063862. Approved by Brandon Schaefer. 2012-10-10 Marco Trevisan (Treviño) TestMatcher: added test for libreoffice window matching 2012-10-10 Marco Trevisan (Treviño) BamfLegacyWindowTest: add function to set wmclass, duplicate provided name 2012-10-09 Marco Trevisan (Treviño) TestWindow: added hints tests 2012-10-09 Marco Trevisan (Treviño) BamfLegacyWindowTest: implement get/set hints also add a finalize function 2012-10-09 Marco Trevisan (Treviño) BamfLegacyWindow: add hint setter/getters (overridable) and use it Matcher and BamfWindow updated 2012-10-09 Marco Trevisan (Treviño) BamfXutils: automatically set/get the atom type for string values 2012-10-09 Marco Trevisan (Treviño) BamfMatcher: also support libreoffice-base dialogs 2012-10-08 Marco Trevisan (Treviño) BamfMatcher: add support for libreoffice Base 2012-10-10 Rico Tzschichholz Autoconf: Exclude generated sources from tarball and fix "make distcheck". Approved by Marco Trevisan (Treviño). 2012-10-09 Rico Tzschichholz Exclude generated sources from tarball and fix "make distcheck" 2012-10-09 Rico Tzschichholz libbamf: gir-annotion fixes and make gi-scanner verbose. Fixes: . Approved by Marco Trevisan (Treviño). 2012-10-08 Rico Tzschichholz libbamf: only perform introspection on public api 2012-10-08 Rico Tzschichholz libbamf: gir-annotion fixes and make gi-scanner verbose 2012-10-08 Rico Tzschichholz Libbamf: Some signal, type and annotation fixes. Fixes: . Approved by Marco Trevisan (Treviño). 2012-10-08 Rico Tzschichholz Signal, type and annotation fixes 2012-10-08 Rico Tzschichholz Autoconf: Make libunity-webapps an optional dependency. Fixes: . Approved by Marco Trevisan (Treviño). 2012-10-08 Rico Tzschichholz build: make libunity-webapps an optional dependency 2012-10-04 Marco Trevisan (Treviño) BamfFactory: don't use the secondary matching method for views with valid .desktop file (LP: #1026426). Fixes: https://bugs.launchpad.net/bugs/1026426. Approved by Timo Jyrinki. 2012-10-04 Marco Trevisan (Treviño) BamfFactory: don't use the secondary matching method for views with valid .desktop file 2012-10-03 Marco Trevisan (Treviño) BamfApplication: set urgency and visibility of an application in any case. 2012-10-01 Łukasz 'sil2100' Zemczak Release 0.3.2 2012-10-01 Marco Trevisan (Treviño) Daemon, BamfApplication: fix a crash on getting the supported mimes Also remove the unneeded mimes_initialized, just use the pointer value and add tests.. Fixes: https://bugs.launchpad.net/bugs/1058260. Approved by Michal Hruby. 2012-10-01 Marco Trevisan (Treviño) Daemon, BamfApplication: no need to have an empty array... Just pass null to g_variant_new_strv 2012-10-01 Marco Trevisan (Treviño) Tests, Daemon: application code cleanup 2012-10-01 Marco Trevisan (Treviño) BamfApplication: use g_variant_new_strv for building string arrays 2012-10-01 Marco Trevisan (Treviño) Daemon, BamfApplication: be safer on managing empty mimes 2012-10-01 Marco Trevisan (Treviño) Daemon, tests: add one more mime types test (for invalid mimes) 2012-10-01 Marco Trevisan (Treviño) Daemon Tests: add test to get supported mime types 2012-09-28 Marco Trevisan (Treviño) Daemon, BamfApplication: fix a crash on getting the supported mimes Also remove the unneeded mimes_initialized, just use the pointer value 2012-09-28 Marco Trevisan (Treviño) libbamf, BamfApplication: remove the useless mimes_initialized variable, just use the pointer 2012-10-01 Maxim Ermilov Daemon, BamfUnityWebApp: don't unref the view when not needed, the matcher will handle that.. Fixes: . Approved by Marco Trevisan (Treviño). 2012-09-30 Maxim Ermilov unity-webapps: remove useless ref/unref pair 2012-09-28 Maxim Ermilov unity-webapps: refcount fixes 2012-09-17 Robert Carr Fix typo in bamf_unity_webapps_application_get_close_when_empty, closes bug 1051042. Fixes: https://bugs.launchpad.net/bugs/1051042. Approved by Marco Trevisan (Treviño). 2012-09-14 Robert Carr Fix typo in bamf_unity_webapps_application_get_close_when_empty closing #1051042 2012-09-03 Łukasz 'sil2100' Zemczak Release 0.3.0 2012-08-22 Robert Carr Add webapps support. Fixes: . Approved by Marco Trevisan (Treviño), Jason Smith. 2012-08-22 Robert Carr Don't unref the UnityWebappsService if we never create it 2012-08-21 Robert Carr Replace tabs with spaces in lib 2012-08-21 Robert Carr Replace tabs with spaces 2012-08-21 Robert Carr Some missing renames 2012-08-21 Robert Carr FocusChild->FocusableChild 2012-08-20 Robert Carr Add BamfApplication::supported_mimes_changed signal 2012-08-19 Robert Carr More review comments integration 2012-08-19 Robert Carr Integrate lots of comments from review 2012-08-17 Robert Carr Extra null check in bamf-unity-webapps-observer 2012-08-17 Robert Carr Refactor BamfUnityWebappsApplicationt o use bamf_application_set_desktop_file_from_id 2012-08-17 Robert Carr Implement bamf_application_set_desktop_file_from_id 2012-08-17 Robert Carr Remove implicit dispose 2012-08-17 Robert Carr Use UNITY_WEBAPPS_CONTEXT_MENU_PATH instead of hardcoded string constant 2012-08-17 Robert Carr Revert filtering of BAMF_WINDOW_DOCK 2012-08-17 Robert Carr Refactor close_when_empty application private variable to class overrideable method 2012-08-17 Robert Carr Rename bamf_application_get_dnd_mimes to bamf_application_get_supported_mime_types on the client side 2012-08-17 Robert Carr Rename DndMimes->SupportedMimeTypes in BamfDaemon 2012-08-11 Ken VanDine dist check fix 2012-08-10 Ken VanDine typo fix + logic fix on visibility flags (Robert Carr) 2012-08-10 Robert Carr typo fix + logic fix on visibility flags 2012-08-10 Ken VanDine manual merge of webapps changes 2012-08-10 Michal Hruby Release 0.2.122 2012-08-01 Marco Trevisan (Treviño) tests: include the tests data dir in distribution. Fixes: . Approved by Łukasz Zemczak. 2012-08-01 Marco Trevisan (Treviño) BamfDaemon, correctly build the gdbus files 2012-08-01 Marco Trevisan (Treviño) Bamfdaemon, put BUILT_SOURCES back 2012-08-01 Marco Trevisan (Treviño) tests: include the tests data dir in distribution 2012-08-01 Łukasz 'sil2100' Zemczak Added some missing header files to src/Makefile.am.. Fixes: . Approved by Sam Spilsbury. 2012-08-01 Łukasz 'sil2100' Zemczak Added the missing files to the src/Makefile.am file 2012-07-31 Michal Hruby Fix non-srcdir build. Fixes: . Approved by Marco Trevisan (Treviño). 2012-07-31 Michal Hruby Fix non-srcdir build 2012-07-31 Marco Trevisan (Treviño) BamfMatcher: don't reopen windows when iterating on view's list, add tests. Fixes: . Approved by Michal Hruby. 2012-07-31 Marco Trevisan (Treviño) BamfLegacyWindowTest: set the window as closed before emitting the signal 2012-07-30 Marco Trevisan (Treviño) BamfLegacyScreen: avoid close event duplication 2012-07-30 Marco Trevisan (Treviño) test-matcher: fix data_dir path 2012-07-28 Marco Trevisan (Treviño) libbamf: put the introspection back 2012-07-28 Marco Trevisan (Treviño) Temporary disable introspection 2012-07-28 Marco Trevisan (Treviño) BamfMatcher: indentation fix 2012-07-28 Marco Trevisan (Treviño) test-matcher: added test for bamf_matcher_load_desktop_file fix 2012-07-28 Marco Trevisan (Treviño) BamfWindow: use %u to get the string form of the xid, or it won't always work! 2012-07-28 Marco Trevisan (Treviño) test-matcher: even more checks for opened windows 2012-07-28 Marco Trevisan (Treviño) test-matcher: tests cleanup (and leak fixes) 2012-07-28 Marco Trevisan (Treviño) test-matcher: add test to match applications with no desktop file 2012-07-28 Marco Trevisan (Treviño) BamfApplication: don't match similar windows if both wmclass name and instance are null 2012-07-28 Marco Trevisan (Treviño) BamfLegacyWindowTest: add wm_class proper support 2012-07-28 Marco Trevisan (Treviño) bamf-legacy-screen: remove closed windows from screen list, emit signal 2012-07-27 Marco Trevisan (Treviño) test-matcher: test desktop applications windows matching 2012-07-27 Marco Trevisan (Treviño) BamfMatcher: expose getters in private header 2012-07-27 Marco Trevisan (Treviño) test-matcher: unref the matcher and screen 2012-07-27 Marco Trevisan (Treviño) BamfLegacyScreen: add finalize function 2012-07-27 Marco Trevisan (Treviño) test_matcher: add tests to load windows 2012-07-27 Marco Trevisan (Treviño) BamfLegacyWindowTest: implement get_window_type 2012-07-27 Marco Trevisan (Treviño) BamfLegacyWindow: add get_window_type to class 2012-07-27 Marco Trevisan (Treviño) BamfLegacyWindowTest: implement the is_closed and reopen functions Also, add a function to copy them 2012-07-27 Marco Trevisan (Treviño) BamfLegacyWindow: add reopen and is_closed functions to the class 2012-07-27 Marco Trevisan (Treviño) BamfLegacyScreen: add private functions in bamf-egacy-screen-private.h They are needed to handle test windows 2012-07-27 Marco Trevisan (Treviño) tests, test_matcher: added loading desktop file tests 2012-07-27 Marco Trevisan (Treviño) BamfMatcher: moved BamfMatcherPrivate definition into bamf-matcher-private.h For testing purposes 2012-07-27 Marco Trevisan (Treviño) bamf-matcher: don't delete views from a list that we're iterating This fixes a crash when a new desktop matching a window has been added. 2012-07-17 Brandon Schaefer Daemon, BamfApplication: Use the default icon if there is not one defined in the desktop file.. Fixes: https://bugs.launchpad.net/bugs/886778. Approved by Marco Trevisan (Treviño). 2012-07-17 Brandon Schaefer * Fix test, and indent 2012-07-12 Brandon Schaefer * Added test 2012-07-11 Brandon Schaefer * If no icon is in the *.desktop file give it the default icon 2012-07-13 Michal Hruby Enable introspection. Fixes: . Approved by Marco Trevisan (Treviño). 2012-07-02 Michal Hruby A bunch of annotation fixes 2012-07-02 Michal Hruby Fix annotation for BamfMatcher.get_default 2012-07-01 Michal Hruby Enable vapigen 2012-07-01 Michal Hruby Suppress giscanner warnings 2012-07-01 Michal Hruby Move doc comments to c files 2012-07-01 Michal Hruby Enable introspection 2012-07-01 Michal Hruby Enable silent rules 2012-07-13 Ying-Chun Liu (PaulLiu) Fix type mismatch in bamf_control_register_application_for_pid() and the dbus interface (LP: #1021143). Fixes: https://bugs.launchpad.net/bugs/1021143. Approved by Marco Trevisan (Treviño). 2012-07-05 Ying-Chun Liu (PaulLiu) Fix type mismatch in bamf-control.c bamf_control_register_application_for_pid() and the dbus interface. (LP: #1021143) 2012-07-04 Michal Hruby Release 0.2.120 2012-06-22 Marco Trevisan (Treviño) BamfMatcher: force a view as closed or not-closed on proper signals. This avoids that a view that is opened is actually marked as closed when really it's running. Fixes #925421. Fixes: https://bugs.launchpad.net/bugs/925421. Approved by Jason Smith. 2012-06-14 Marco Trevisan (Treviño) Daemon, BamfView: correctly free the object interfaces list 2012-06-13 Marco Trevisan (Treviño) BamfMatcher: force a view as closed or not-closed on proper signals. This avoids that a view that is opened is actually marked as closed when really it's running. Fixes #925421 2012-06-13 Marco Trevisan (Treviño) BamfView: add a private function to set a view as closed 2012-06-22 Marco Trevisan (Treviño) libbamf, bamf-view: don't unset the proxy on closed sticky views Also, don't reset the proxy if the current one is still valid.. Fixes: https://bugs.launchpad.net/bugs/976642. Approved by Jason Smith. 2012-06-15 Marco Trevisan (Treviño) BamfView: a view is not remote-ready if it has been closed. Fixes warning on closed sticky views. 2012-06-13 Marco Trevisan (Treviño) BamfFactory: clean-up the registered_views list when destroying them 2012-06-13 Marco Trevisan (Treviño) libbamf, BamfView: don't re-set the proxy if the current one is still valid 2012-06-13 Marco Trevisan (Treviño) libbamf, bamf-view: don't unset the proxy on closed sticky views 2012-06-20 Didier Roche remerge libbamf, Makefile: don't export private symbols (factory and matcher) 2012-05-25 Marco Trevisan (Treviño) libbamf, Makefile: don't export private symbols (factory and matcher). Fixes: . Approved by Sebastien Bacher. 2012-05-24 Marco Trevisan (Treviño) libbamf: use '_' prefix for private symbols 2012-05-24 Marco Trevisan (Treviño) libbamf, Makefile: no need to use {1} in regex... 2012-05-24 Marco Trevisan (Treviño) BamfApplication: rename private member using the bamf_priv_ prefix 2012-05-24 Marco Trevisan (Treviño) libbamf, Makefile: don't export private symbols (factory and matcher) 2012-06-20 Didier Roche releasing 0.2.118 2012-05-22 Marco Trevisan (Treviño) BamfMatcher: when a new .desktop file is added, try to rematch it to opened applications. Fixes: https://bugs.launchpad.net/bugs/1003005. Approved by Jason Smith. 2012-05-22 Marco Trevisan (Treviño) BamfMatcher: s/l/vl/;/ll/wl/... 2012-05-22 Marco Trevisan (Treviño) BamfMatcher: when a new .desktop file is added, try to rematch it to opened applications 2012-05-22 Marco Trevisan (Treviño) BamfMatcher: use both instance and class names for matching WMClass Also, filter out the .desktop files that have a defined StartupWMClass that doesn't match with our .desktop file.. Fixes: https://bugs.launchpad.net/bugs/692462. Approved by Jason Smith. 2012-05-22 Marco Trevisan (Treviño) Merging with trunk 2012-05-21 Marco Trevisan (Treviño) BamfMatcher: ensure that both possible_applications_for_window and setup_window_state use the same class Plus some minor cleanup 2012-05-15 Marco Trevisan (Treviño) BamfApplication: indentation fixes 2012-04-29 Marco Trevisan (Treviño) BamfMatcher: removed debug symbols 2012-04-29 Marco Trevisan (Treviño) BamfApplication: use a favorite only if the desktop class matches 2012-04-29 Marco Trevisan (Treviño) BamfMatcher: add bamf_matcher_get_desktop_file_class public function 2012-04-29 Marco Trevisan (Treviño) BamfMatcher: some code cleanup 2012-04-29 Marco Trevisan (Treviño) BamfMatcher: use both instance and class names for matching WMClass Also, filter out the .desktop files that have a defined StartupWMClass that doesn't match with our .desktop file. 2012-04-29 Marco Trevisan (Treviño) BamfMatcher: emit the RunningApplicationsChanged for closed applications 2012-05-22 Marco Trevisan (Treviño) BamfMatcher: match chromium web applications with no .desktop file as new applications. Fixes: https://bugs.launchpad.net/bugs/692462. Approved by Jason Smith. 2012-04-26 Marco Trevisan (Treviño) BamfMatcher: allow to create new web applications with no desktop 2012-05-22 Marco Trevisan (Treviño) BamfMatcher must emit the "running-applications-changed" signal for closed applications.. Fixes: https://bugs.launchpad.net/bugs/989551. Approved by Gord Allott. 2012-04-27 Marco Trevisan (Treviño) BamfMatcher: emit the RunningApplicationsChanged for closed applications 2012-05-17 Marco Trevisan (Treviño) libbamf: unset the previously defined proxy if adding a new one This fixes some crashes, and memory leaks.. Fixes: https://bugs.launchpad.net/bugs/995916, https://bugs.launchpad.net/bugs/999820, https://bugs.launchpad.net/bugs/1000577. Approved by Tim Penhey, Andrea Azzarone. 2012-05-17 Marco Trevisan (Treviño) libbamf: unset the previously defined proxy if adding a new one This fixes some crashes, and memory leaks. 2012-05-17 Marco Trevisan (Treviño) libbamf, BamfApplication: add a sanity check to prevent crash on signals 2012-04-27 Marco Trevisan (Treviño) BamfFactory: be more smart to re-associate a dbus path to a view using windows xid. Fixes: https://bugs.launchpad.net/bugs/928912. Approved by Michal Hruby. 2012-04-26 Marco Trevisan (Treviño) BamfFactory: use BamfFactoryViewType instead of strings comparisons when possible. This cleans the code and is for sure more safe. 2012-04-26 Marco Trevisan (Treviño) libbamf, bamfview: disconect to the destroyed signal when needed 2012-04-26 Marco Trevisan (Treviño) BamfView: reset flags and nullify proxy on proxy destruction 2012-04-26 Marco Trevisan (Treviño) BamfFactory: try to re-associate also windows by xids This shouldn't be needed since the path is not changed in this case but, let's be safe! 2012-04-26 Marco Trevisan (Treviño) BamfFactory: use also the childen xids to match views When bamfdaemon has been killed and re-opened, the library should try to reassociate the opened applications by desktop files, if that check fails we should fallback on the children xids comparison: if at least one child of a closed bamf application matches, then we should re-associate it with the new path. 2012-04-26 Marco Trevisan (Treviño) BamfApplication: add protected get_cached_xids function, to retrieve the children xids We keep in cache a list of xids that the application owns. Available only to the library, not outside 2012-04-23 Marco Trevisan (Treviño) BamfApplication: fix memory leak on get_windows 2012-04-23 Marco Trevisan (Treviño) BamfApplication: use typed factory getter 2012-04-23 Marco Trevisan (Treviño) BamfWindow: use typed factory getter 2012-04-23 Marco Trevisan (Treviño) BamfMatcher: use factory's view_for_path_type function to get BamfView's This should increase the performances when creating a new view, since we don't need to create an unneeded view, fetch for its type, and finally re-create the correctly typed view. Now we do all in one step if possible. 2012-04-23 Marco Trevisan (Treviño) BamfFactory: add bamf_factory_view_for_path_type to reduce the type computation It avoids to create a fake view only to fetch the type when it's already known. 2012-04-26 Gord Allott Release 0.2.116 2012-04-24 Marco Trevisan (Treviño) BamfLegacyWindow and BamfMatcher changes needed to get the proper WM_CLASS / desktop-class matching in BAMF.. Fixes: https://bugs.launchpad.net/bugs/692462. Approved by Jason Smith. 2012-04-20 Marco Trevisan (Treviño) BamfMatcher: oops... Forgot an else when checking the type of new application we should create 2012-04-20 Marco Trevisan (Treviño) BamfMatcher: be more explicit about the desktop file to use for a new application. 2012-04-20 Marco Trevisan (Treviño) BamfMatcher: free the temporary list we use to order the windows by stack 2012-04-19 Marco Trevisan (Treviño) BamfXutils: code style fixes 2012-04-19 Marco Trevisan (Treviño) BamfMatcher: copyright updated. 2012-04-19 Marco Trevisan (Treviño) BamfMatcher: use better desktop class-based matching, code cleanup and WebApps fixes 2012-04-19 Marco Trevisan (Treviño) BamfView: export views over dbus in bottom to top order. 2012-04-19 Marco Trevisan (Treviño) BamfLegacyWindow: don't crash if not getting all the windo getometries 2012-04-19 Marco Trevisan (Treviño) BamfXutils: don't return emtpy strings, only NULL 2012-04-18 Marco Trevisan (Treviño) BamfLegacyWindow: use wnck_window_get_class_group_name when possible or fallback to xutils 2012-04-18 Marco Trevisan (Treviño) BamfLegacyWindow: implement get_class_instance_name also for non-gtk3 builds 2012-04-18 Marco Trevisan (Treviño) BamfXUtils: added bamf_xutils_get_window_class_hints for fallback support Also, we try to avoid to open a new display to get the class and instance names. 2012-04-24 Marco Trevisan (Treviño) libbamf, BamfMatcher: added finalize and dispose functions to disconnect to proxy when destructed. Fixes: . Approved by Michal Hruby. 2012-04-24 Marco Trevisan (Treviño) libbamf, BamfMatcher: add dispose function. 2012-04-22 Charles Kerr BamfView: invoke the invoke the superclass' dispose. Fixes: https://bugs.launchpad.net/bugs/986888. Approved by Marco Trevisan (Treviño). 2012-04-22 Charles Kerr have BamfView's dispose() method properly chain up to the superclass' dispose() 2012-04-18 Marco Trevisan (Treviño) libbamf, BamfFactory: don't cast a view to application if is not a bamf-application. Fixes: . Approved by Michal Hruby, Andrea Azzarone. 2012-04-18 Marco Trevisan (Treviño) libbamf, BamfFactory: don't cast a view to application if is not an application This fixes some unity warnings on reload. 2012-04-10 Thomi Richards Fixed a memory leak in libbamf.. Fixes: . Approved by Gord Allott. 2012-04-10 Thomi Richards Fixed memory leak in libbamf. 2012-03-23 Michal Hruby Release 0.2.114 2012-03-20 Marco Trevisan (Treviño) Fix memory leaks and some read errors in Bamf. Fixes: https://bugs.launchpad.net/bugs/929468. Approved by Michal Hruby. 2012-03-19 Marco Trevisan (Treviño) BamfMatcher: rename bamf_matcher_register_view into bamf_matcher_register_view_stealing_ref 2012-03-19 Marco Trevisan (Treviño) BamfMatcher: use a while loop in dispose function, to unregister views. 2012-03-19 Marco Trevisan (Treviño) BamfMatcher: moving to g_list_find + g_list_delete_link 2012-03-19 Marco Trevisan (Treviño) BamfMatcher: cleanup bamf_matcher_unregister_view 2012-03-16 Marco Trevisan (Treviño) BamfMatcher: Reset the active app / window when unregistering them This fixes some Valgrind read errors. 2012-03-16 Marco Trevisan (Treviño) BamfMatcher: even less memory leaks... Protecting from get_window_hint! 2012-03-16 Marco Trevisan (Treviño) BamfView: use constant strings when possible (plus one memory leak, for free). Fixed the memory leak in BamfApplication (when checking the bamf name) 2012-03-16 Marco Trevisan (Treviño) BamfMatcher: g_ascii_strdown already duplicate a string. One more mem-leak fixed... 2012-03-16 Marco Trevisan (Treviño) BamfMatcher: don't leak memory on load_desktop_file_to_table Avoid to unref the GDesktopAppInfo value 2012-03-16 Marco Trevisan (Treviño) BamfMatcher: make sure we also free a trimmed exec string. 2012-03-16 Marco Trevisan (Treviño) BamfMatcher: free the read line in load_index_file_to_table 2012-03-16 Marco Trevisan (Treviño) BamfMatcher: set to null the static matcher on finalize 2012-03-16 Marco Trevisan (Treviño) BamfMatcher: don't leak memory when parsing normal files on get_directory_tree_list 2012-03-12 Michal Hruby Release 0.2.112 2012-02-28 Ryan Lortie In libbamf BamfMatcher Don't ref/unref views when they are opened/closed When a "Opened" signal comes from bamf, the client side matcher gets the view for the path and refs it. on "Closed" it unrefs it. the problem comes when you close a window that was open when the application using bamf started running. in that case, the client library sees "Closed" with no "Opened" and drops a reference that it doesn't own. UNBLOCK. Fixes: https://bugs.launchpad.net/bugs/942070. Approved by Marco Trevisan (Treviño). 2012-02-28 Ryan Lortie fix refcounting of views in the matcher --fixes lp:942070 2012-02-27 Michal Hruby Let's make these changes by Jason land ;). Fixes: . Approved by Marco Trevisan (Treviño). 2012-02-27 Michal Hruby Merge with trunk 2012-02-27 Michal Hruby Re-add a function lost in the void during merges 2012-02-27 Ted Gould Fixes a case where there is no session bus to be found.. Fixes: . Approved by Marco Trevisan (Treviño). 2012-02-16 Ted Gould Attaching bug 2012-02-16 Ted Gould Allow for failure if we get an error set 2012-02-27 Marco Trevisan (Treviño) Fixed the Coverity warning.. Fixes: https://bugs.launchpad.net/bugs/937398. Approved by Jason Smith. 2012-02-25 Marco Trevisan (Treviño) Fix Coverty hidden parameter issue 2012-02-27 Marco Trevisan (Treviño) Making libbamf correctly free items when disposing BamfView and BamfControl, plus some misc cleanups. Fixes: https://bugs.launchpad.net/bugs/942148. Approved by Jason Smith. 2012-02-27 Marco Trevisan (Treviño) libbamf, BamfView: free cached string values on dispose 2012-02-27 Marco Trevisan (Treviño) libbamf, BamfWindow: remove unneeded values from the private struct 2012-02-27 Marco Trevisan (Treviño) libbamf, BamfControl: add dispose class to unref the proxy 2012-02-24 Charles Kerr . Fixes: https://bugs.launchpad.net/bugs/937402. Approved by Marco Trevisan (Treviño). 2012-02-21 Charles Kerr Fix LP Bug #937402 the GList variable "views" wasn't initialized to NULL before we start prepending to it. 2012-02-17 Michal Hruby Merge trunk 2012-02-16 Marco Trevisan (Treviño) Let's make these changes by Jason land ;). Fixes: . Approved by Marco Trevisan (Treviño). 2012-02-15 Marco Trevisan (Treviño) Merging with trunk 2012-02-01 Marco Trevisan (Treviño) Moving to UINT to handle window PID... 2012-01-30 Jason Smith export PID over bus 2012-02-17 Michal Hruby Release 0.2.110 2012-02-16 Sven Baars Make sure the result of g_dbus_proxy_call_sync is unreffed. g_dbus_proxy_call_sync returns a non-floating GVariant.. Fixes: . Approved by Marco Trevisan (Treviño). 2012-02-11 Sven Baars Make sure the result of g_dbus_proxy_call_sync is unreffed 2012-02-15 Jason Smith UNBLOCK Gets rid of cache tracking and simply invalidates cache when add or remove signals are received.. Fixes: . Approved by Gord Allott. 2012-02-15 Jason Smith fix ;; 2012-02-15 Jason Smith commit evil 2012-02-10 Jason Smith Fix approved in IRC by desrt. Fixes: . Approved by . 2012-02-10 Jason Smith I should retire... 2012-02-10 Jason Smith Make sure we actually get UTF8 strings when needed. Fixes: . Approved by Ted Gould. 2012-02-10 Jason Smith make sure we actually get UTF8 strings when requested 2012-02-10 Jason Smith Implements updates to the dbus menu spec (new atoms mostly) Merge does not contain tests. Tests will be covered in User Acceptance testing in Unity later when the required dependencies for the tests are available.. Fixes: . Approved by Ted Gould. 2012-02-10 Jason Smith oops 2012-02-10 Jason Smith naming 2012-02-10 Jason Smith just export xprop so consumers may use props as they like 2012-02-10 Jason Smith update because ted and desrt cant name things clearly 2012-02-10 Jason Smith update to match dbusmenu changes 2012-02-09 Marco Trevisan (Treviño) Some bool are returned on non-gboolean functions, fixed them plus a gerror memory leak. Fixes: . Approved by Michal Hruby. 2012-02-09 Marco Trevisan (Treviño) Merging with trunk 2012-02-06 Marco Trevisan (Treviño) libbamf: fixed some retourn and memory leaks 2012-02-09 Sven Baars This should fix ==1933== 96 bytes in 8 blocks are definitely lost in loss record 8,181 of 10,585 ==1933== at 0x4C296CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1933== by 0x6710918: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3116.0) ==1933== by 0x6702A4C: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3116.0) ==1933== by 0x6703DDF: g_key_file_get_string (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3116.0) ==1933== by 0x2366A677: bamf_application_new_favorite (in /usr/lib/x86_64-linux-gnu/libbamf3.so.0.0.0) ==1933== by 0x2366F34F: bamf_factory_app_for_file (in /usr/lib/x86_64-linux-gnu/libbamf3.so.0.0.0) ==1933== by 0x2366C023: bamf_matcher_get_application_for_desktop_file (in /usr/lib/x86_64-linux-gnu/libbamf3.so.0.0.0) ==1933== by 0x22D83554: unity::launcher::Controller::Impl::CreateFavorite(char const*) (in /usr/lib/compiz/libunityshell.so) ==1933== by 0x22D8623B: unity::launcher::Controller::Impl::SetupBamf() (in /usr/lib/compiz/libunityshell.so) ==1933== by 0x22D865A8: ??? (in /usr/lib/compiz/libunityshell.so) ==1933== by 0x670B76A: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3116.0) ==1933== by 0x670AB29: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3116.0). Fixes: . Approved by Michal Hruby. 2012-02-08 Sven Baars Free a newly allocated string after use (Valgrind) 2012-02-08 Sven Baars This should fix ==1994== 49 (16 direct, 33 indirect) bytes in 1 blocks are definitely lost in loss record 11,086 of 25,065 ==1994== at 0x4C296CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1994== by 0x4C29857: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1994== by 0x670D9D6: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3116.0) ==1994== by 0x66DCB58: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3116.0) ==1994== by 0x66DCCD3: g_array_sized_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3116.0) ==1994== by 0x10EC9D96: ??? (in /usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2.2.2) ==1994== by 0x10ECAAD4: ??? (in /usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2.2.2) ==1994== by 0x10EC437C: ??? (in /usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2.2.2) ==1994== by 0x10EC769A: dbus_g_proxy_call (in /usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2.2.2) ==1994== by 0x1B0DB81E: bamf_view_get_children (in /usr/lib/x86_64-linux-gnu/libbamf3.so.0.0.0) ==1994== by 0x19EE94B3: unity::launcher::BamfLauncherIcon::EnsureWindowState() (in /usr/lib/compiz/libunityshell.so) ==1994== by 0x19EE9B87: unity::launcher::BamfLauncherIcon::BamfLauncherIcon(_BamfApplication*) (in /usr/lib/compiz/libunityshell.so). Fixes: . Approved by Mikkel Kamstrup Erlandsen. 2012-02-07 Sven Baars Fix a memory leak when an error is returned by dbus_g_proxy_call (Valgrind) 2012-02-07 Marco Trevisan (Treviño) Makes bamf not double add items if the user calls get_children before a child-added signal arrives.. Fixes: https://bugs.launchpad.net/bugs/928014. Approved by Tim Penhey. 2012-02-07 Marco Trevisan (Treviño) bamf-view: Indentation fix 2012-02-07 Marco Trevisan (Treviño) Adding m4 directoty not to make autogen to fail 2012-02-06 Jason Smith remove m4 subfolder as it shouldn't have been in VCS anyhow 2012-02-06 Jason Smith prevent double adding of children when signal comes in late 2012-02-03 Didier Roche releasing 0.2.108 2012-01-27 Marco Trevisan (Treviño) Libreoffice desktop files have changed the exec parameter in last upgrade, we need to match them correctly. Code updated to support both the old and the new lo .desktop files.. Fixes: https://bugs.launchpad.net/bugs/919892. Approved by Jason Smith. 2012-01-23 Marco Trevisan (Treviño) BamfMatcher: update libreoffice special code to handle the new "double-dashed" parameter New Libreoffice uses two dashes to launch its tools, updating the special code to handle this. 2012-01-27 Marco Trevisan (Treviño) Fixed bug bug #801784 making gnome-control-center to rematch in BAMF Used a similar hack used for re-matching libreoffice. Here the gnome-control-center window is rematched when its name changes, getting its ID from the defined WM_WINDOW_ROLE. Also I've fixed a bug that caused all the gnome-control-center desktop to be ignored by the matcher, only the last parsed was considered by bamf before (due to this when doing "gnome-control-center display" in a terminal, the window was matched as a generic g-c-c window, not as the display one). To do this, I've added a white-list regex to match the prefixes that must not be ignored and that should be included into the exec string (I guess that this can be useful also for fixing the matching of the wine apps). Note that this branch to work correctly needs lp:~3v1n0/ubuntu/precise/gnome-control-center/add-window-role-to-panels If no patched gnome-control-center is found, all the gnome-control-center windows will always be shown as generic g-c-c windows.. Fixes: https://bugs.launchpad.net/bugs/801784. Approved by . 2012-01-26 Marco Trevisan (Treviño) BamfMatcher: don't include bzr as a good prefix. 2012-01-21 Marco Trevisan (Treviño) Matcher: add support to Gnome Control Center rematching. Using an hack similar to the one used in libreoffice to match the gnome-control-center window changes, here instead we use the WM_WINDOW_ROLE hint (set in the g-c-c side) to check if the gnome control center window has changed role (i.e its content type). Also, fixed an issue that caused BAMF to ignore the desktop files with an exec string with multiple strings (such as the gnome-control-center uses). Now we match all these desktop files using a white list. 2012-01-27 Marco Trevisan (Treviño) Fixed bug #919366 that was caused by the fact that the list of the cached children were not correctly updated on children removal. Reffing the objects on the list and manually looking for the removed one, does the work. In the case we can't find the removed object, we just free the cached list, that will be eventually repopulated on next request.. Fixes: https://bugs.launchpad.net/bugs/919366. Approved by Jason Smith. 2012-01-28 Marco Trevisan (Treviño) Updated Jason's cached children fix against new code. 2012-01-28 Marco Trevisan (Treviño) Merging with trunk. 2012-01-28 Marco Trevisan (Treviño) lib, BamfView: fixed typo that lead to a crash. Now the removed children are found correctly. 2012-01-20 Marco Trevisan (Treviño) BamfView: cached children should be reff'ed and manually searched on removal A bamf view get unreffed when it is closed, so when a child is removed bamf_factory_view_for_path won't work. So we need to ref our cached children and manually look for the right cached children when removing it. 2012-01-20 Marco Trevisan (Treviño) LibBamf, view, matcher: always keep the order of the lists we get from dbus Using reverse-foreach + prepend is both optimized and functional. 2012-01-20 Marco Trevisan (Treviño) LibBamf: make bamf-marshal.h private again. 2012-01-20 Marco Trevisan (Treviño) Merging with upstream 2012-01-24 Jason Smith . Fixes: . Appoved by Andrea Azzarone. 2012-01-24 Jason Smith fix issue in bamf view caching of children where children cache wasn't wiped on closing of a sticky application 2012-01-20 Michal Hruby Added method and signal to list desktop file paths of running applications, this is needed for application lens, which should exclude running applications from the default results and we need to minimize the number of wakeups of the lens daemon.. Fixes: . Appoved by Marco Trevisan (Treviño), Mikkel Kamstrup Erlandsen. 2012-01-20 Michal Hruby Merge trunk 2012-01-17 Michal Hruby Merge trunk 2012-01-17 Michal Hruby Use a timeout instead of idle callback 2012-01-13 Michal Hruby Add method and signal to get just the desktop file paths of running applications 2012-01-12 Michal Hruby Return non-duplicated strings for desktop files 2012-01-19 smspillaz Collects existing merges from Marco (sorry, we need this merged) and fixes conflicts/naming. Fixes: . Appoved by Marco Trevisan (Treviño), Michal Hruby, Andrea Azzarone. 2012-01-19 Marco Trevisan (Treviño) Merging with new upstream. 2012-01-18 Michal Hruby This should do it 2012-01-18 Jason Smith fix crash when closing windows in certain condition 2012-01-18 Michal Hruby We're getting somewhere 2012-01-18 Michal Hruby Removed too much 2012-01-18 Michal Hruby Give it one more try 2012-01-18 smspillaz Also include /src in lib/ and src/ 2012-01-18 smspillaz Also search the src/ directories for includes A note here that autotools behaviour for doing in source builds is incredibly broken in so many ways. 2012-01-17 Jason Smith install bamf-marshal.h 2012-01-17 Jason Smith cache get_children results locally to avoid dbus-chattiness 2012-01-17 Jason Smith fix naming to be C++ friendly 2012-01-17 Jason Smith merge lib bamf net hints 2012-01-17 Jason Smith merge bamf daemon side net hints 2012-01-17 Jason Smith merge trunk 2012-01-19 Marco Trevisan (Treviño) Added the wrapper functions for the new DBus APIs defined in lp:~3v1n0/bamf/bamfdaemon-net-dbus-hints. Fixes: . Appoved by . 2012-01-19 Marco Trevisan (Treviño) Fixed build issues, thanks to branch lp:~unity-team/bamf/bamf.merge-resolve 2012-01-19 Marco Trevisan (Treviño) Merging with upstream. 2012-01-19 Marco Trevisan (Treviño) libbamf, BamfWindow: remove "new" named variables from the BamfWindow header. 2012-01-11 Marco Trevisan (Treviño) BamfView: fixed some few leaks and logic errors. 2012-01-10 Marco Trevisan (Treviño) BamfMatcher: start from length-1 when reversing foreach. 2012-01-10 Marco Trevisan (Treviño) Merging with recent changes in lp:~3v1n0/bamf/bamfdaemon-net-dbus-hints 2012-01-10 Marco Trevisan (Treviño) BamfMatcher: signal on stacking-order change and add new method for getting windows in stack order 2012-01-10 Marco Trevisan (Treviño) BamfView: fix memory leaks 2012-01-10 Marco Trevisan (Treviño) BamfWindow: add support to new dbus_hint methods and signals 2012-01-19 Marco Trevisan (Treviño) Implemented the _DBUS_APPLICATION_ID, _DBUS_UNIQUE_NAME, and _DBUS_OBJECT_PATH support Added more APIs to get more informations from a window, and to get the stacked windows per monitor.. Fixes: . Appoved by Jason Smith. 2012-01-10 Marco Trevisan (Treviño) BamfDaemon, add more window tests. 2012-01-10 Marco Trevisan (Treviño) BamfDaemon, added tests for Maximized signal. 2012-01-10 Marco Trevisan (Treviño) BamfLegacyScreen: allow to add more informations via state-files 2012-01-10 Marco Trevisan (Treviño) BamfLegacyWindow: implemented the missing interface functions. 2012-01-10 Marco Trevisan (Treviño) BamfLegacyWindow, improved the class to allow better tests. 2012-01-10 Marco Trevisan (Treviño) BamfMatcher: return all the stacked windows when using a negative monitor value 2012-01-10 Marco Trevisan (Treviño) BamfDaemon, update the bamf matcher dbus APIs 2012-01-09 Marco Trevisan (Treviño) BamfMatcher: emit the StackingOrderChanged signal 2012-01-09 Marco Trevisan (Treviño) BamfMatcher: allow to get stacked windows for monitor. 2012-01-09 Marco Trevisan (Treviño) BamfWindow: Allow to get the window position on stack. 2012-01-09 Marco Trevisan (Treviño) BamfLegacyWindow: add a getter function to retrieve the stacking position 2012-01-09 Marco Trevisan (Treviño) BamfLegacyScreen: order windows by legacy screen stack order. 2012-01-09 Marco Trevisan (Treviño) BamfWindow: implement the BamfDBusItemWindowIface interface This allows to emit signals also to our derived classes (if any) 2012-01-09 Marco Trevisan (Treviño) BamfWindow: added new Window interface A BamfWindow now exports the app-id, the bus-name, the menu-object the maximized status and its monitor. 2012-01-09 Marco Trevisan (Treviño) BamfLegacyWindow: added signals for geometry changed 2012-01-09 Marco Trevisan (Treviño) BamfLeagcyWindow: added some more needed functions /jason designing, /me wrinting :) 2012-01-09 Marco Trevisan (Treviño) BamfMatcher: using BamfXutils 2012-01-09 Marco Trevisan (Treviño) Added Bamf xutils for utility functions 2012-01-19 Marco Trevisan (Treviño) Ported the BAMF daemon to GDBus, using gdbus-codegen to generate most of the low-level code. The BamfMatcher and BamfControl are directly extending the generated skeleton class, while the Views are now extending the generated BamfDBusItemObjectSkeleton class, so it has been easily possible to transform each subclass into a kind of proxy to the generated skeleton interface. To reduce code redundancy for initializing signals, some view classes are also implementing the related skeleton interface, but this has been done only for convenience. Then, I've added a BamfDaemon class to handle the daemon initialization and termination, and I've updated the tests against the new internal APIs. Finally, I've also ported all the code for indicators and tabs, while I guess that this is now quite obsolete (the indicator part shouldn't totally, but the tabs really are), so maybe it could safely be removed. I also want to make clear that the public DBus API interface has not been touched by this porting, so the new bamfdaemon can safely replace the old one (in fact I'm using it on my PC for some days with no crashes or unexpected behavior). The port of libbamf will begin soon as well, and doing that maybe we should refine also the DBus interface. PS: of course I've also included some random code fixes and cleanup.. Fixes: https://bugs.launchpad.net/bugs/697148. Appoved by Jason Smith. 2012-01-19 Marco Trevisan (Treviño) tests, BamfDaemon: removed typo. 2012-01-19 Marco Trevisan (Treviño) tests, Bamfdaemon: Don't kill Xvfb on test. 2012-01-19 Marco Trevisan (Treviño) tests, BamfDaemon: no need to kill the session bus, Xvfb is enough. 2012-01-19 Marco Trevisan (Treviño) BamfDaemon tests: use srcdir when looking for run-xvfb.sh 2012-01-19 Marco Trevisan (Treviño) tests, BamfDaemon: using run-xvfb.sh script from dbusmenu, to run xvfb 2012-01-19 Marco Trevisan (Treviño) BamfDaemon tests: increase the timeout and use verbose output 2012-01-19 Marco Trevisan (Treviño) test-bamf: use the session bus for testing. 2012-01-19 Marco Trevisan (Treviño) Tests: using gtk_init instead of g_type_init 2012-01-19 Marco Trevisan (Treviño) Merging with upstream 2012-01-03 Marco Trevisan (Treviño) BamfDaemon: the IndicatorApprover code is deprecated, so we can avoid to enable it. 2012-01-03 Marco Trevisan (Treviño) BamfDaemon: use g_clear_error when possible. 2012-01-03 Marco Trevisan (Treviño) BamfDaemon: always use GList*, and never const GList* 2011-12-28 Marco Trevisan (Treviño) BamfMatcher: correctly initialize empty arrays. I had done this before, then I reverted but I was wrong. Opening the array is totally needed. 2011-12-27 Marco Trevisan (Treviño) BamfView: emit the closed signal before of the "closed" one Otherwise libbamf has some issues, we need to send the "Closed" signal for a view (and finally unref it) as the last thing. 2011-12-27 Marco Trevisan (Treviño) BamfView: there's no need to ref/unref a removed view now. 2011-12-27 Marco Trevisan (Treviño) BamfView: emit the child-removed signal before of actually removing it This fixes an error that occurred trying to close an application, due to a race. In fact, when removing the last child of an application, the view emitting the child-removed signal were already destroied when trying to use it to emit that signal. 2011-12-23 Marco Trevisan (Treviño) BamfDaemon: set exit on close for connection 2011-12-23 Marco Trevisan (Treviño) Tests: updating copyright. 2011-12-23 Marco Trevisan (Treviño) BamfTest: set the result value to error by default. 2011-12-23 Marco Trevisan (Treviño) Tests: No need to build using the dbus cflags/libs anymore 2011-12-23 Marco Trevisan (Treviño) Moving the BamfDBusObject to BamfDBusItemObject only for views. Splitting the BAMF dbus interfaces into two parts, in one there are the main objects such as Controller and Matcher, while in another there are the Views sub-objects. 2011-12-23 Marco Trevisan (Treviño) test-bamf: ported bamfdaemon tests to GDBus. 2011-12-23 Marco Trevisan (Treviño) BamfView: Always emit signals with valid strings. Plus, don't try to un-export not exported interfaces. 2011-12-23 Marco Trevisan (Treviño) BamfMatcher: remove some debug code. 2011-12-22 Marco Trevisan (Treviño) BamfDaemon: added BamfDaemon class to handle the daemon initalization This is an utility class that initializes the needed services and then starts the main loop. So we can clean the code in main() keeping our initialization code alltogether 2011-12-22 Marco Trevisan (Treviño) BamfDaemon: rewritten the dbus code to use GDBus. I'm mostly using code generated by gdbus-codegen, then: BamfMatcher and BamfControl are now sub-class of the skeleton classes so, we can avoid code duplication for signals and we can just emit signals on the object itself or connect to it to handle dbus method calls. BamfView is instead child of BamfDBusObject and while the views that need to implement some dbus signals are also implementing the proper interface. Then each view when initalized add his own interface to the BamfDBusObject. 2012-01-12 Didier Roche releasing 0.2.106 2011-12-15 Marco Trevisan (Treviño) Fixed LibreOffice and OpenOffice compatibility, remapping windows to their real type. Fixes: https://bugs.launchpad.net/bugs/741995, https://bugs.launchpad.net/bugs/840000, https://bugs.launchpad.net/bugs/842566, https://bugs.launchpad.net/bugs/861355. Appoved by Mikkel Kamstrup Erlandsen. 2011-12-15 Marco Trevisan (Treviño) BamfMatcher: fixing typo s/dispose/finalize/ 2011-12-15 Marco Trevisan (Treviño) BamfMatcher: correctly match the libreoffice transient windows. We'll use the class name for matching them. This allows to be even more precise. 2011-12-14 Marco Trevisan (Treviño) BamfLegacyWindow: added docs to bamf_legacy_window_reopen 2011-12-14 Marco Trevisan (Treviño) BamfLegacyScreen: added docs to bamf_legacy_screen_inject_window 2011-12-14 Marco Trevisan (Treviño) BamfView: emit a g_critical message when unregistering a DBus object 2011-12-14 Marco Trevisan (Treviño) BamfMatcher: use finalize function, instead of dispose. 2011-12-14 Marco Trevisan (Treviño) Configure.in: set glib-2.0 >= 2.28 to support g_list_free_full 2011-12-14 Marco Trevisan (Treviño) BamfApplication: don't leak the icon string 2011-12-10 Marco Trevisan (Treviño) BamfMatcher: Don't use the window class as a parameter for OpenOffice It can be confusing, let's use only the window title. 2011-12-10 Marco Trevisan (Treviño) BamfMatcher: don't handle the openoffice windows typed as splash or toolbar This fixes bug #840000 2011-12-10 Marco Trevisan (Treviño) BamfMatcher: Adding myself to the authors. 2011-12-10 Marco Trevisan (Treviño) BamfMatcher: added dispose function. When needed, correctly frees all the bamf data. 2011-12-10 Marco Trevisan (Treviño) BamfMatcher: Using direct HashTable instead of *int-based for PIDs This improves speed and fixes a lot of memory leaks (keys and values were never free'd) in the matcher. 2011-12-10 Marco Trevisan (Treviño) BamfMatcher: Correcly match OpenOffice / LibreOffice windows to the right application. When a window can be mapped as a LibreOffice / OpenOffice application we look for the right hint for the given window, we set that hint by default (if valid) and we connect to the window's name-changed event. So, every time the window name changes, we check again for the window type and if it has changed (i.e. we moved from writer to start-center), then we simulate a window open/close event that cause the window to be re-mapped to the proper application. This works very well and allows to change the application type on run-time. Also, every recognized libreoffice window that doesn't match any main application, is now considered as a "Standard" libreoffice application window, using the libreoffice-startcenter icon. This allows to correctly match not only the start center, but also dialog windows such as the restore window that shows up after a crash. The slash screen is now ignored, and so doesn't respect the rules above. Plus some optimizations and code cleanup. 2011-12-10 Marco Trevisan (Treviño) BamfLegacyWindow: add bamf_legacy_window_reopen This utility function allows to set a BamfLegacyWindow as closed, notifying all its owners, and to reopen it once the current window has been destroyed. This will allow to remap particular windows as different applications. 2011-12-10 Marco Trevisan (Treviño) BamfLegacyScreen: add bamf_legacy_screen_inject_window This function allow to push into the screen a window by its xid. If the window is already known, it's just ignored, otherwise it's added to the windows list. 2011-12-10 Marco Trevisan (Treviño) BamfView: avoid to export an object with alredy used path. Emit a g_critical message, instead of crashing, and replace the old object with the new one. 2011-12-10 Marco Trevisan (Treviño) BamfApplication: avoid to create an icon using a null GIcon 2011-12-09 Marco Trevisan (Treviño) BamfLegacyWindow: remove the double check on window_closed. Typo... :) 2011-12-09 Marco Trevisan (Treviño) BamfLegacyWindow: check if we're closing the current window before setting it as closed This bug caused that when a window was closed, then also all the other opened windows were marked as "closed". It also fixes bug #842566 2011-12-07 Marco Trevisan (Treviño) BAMF doesn't consider any .desktop file saved in ~/.local/share/applications or any other local folder which contains the flag OnlyShowIn=GNOME;Unity; so, it's impossible to directly copy any .desktop file from /usr/share/applications to a local folder to customize it, without removing the above flag, and this is wrong. This patch fixes the issue.. Fixes: https://bugs.launchpad.net/bugs/863290. Appoved by Jason Smith. 2011-09-29 Marco Trevisan (Treviño) matcher: some code cleanup 2011-09-29 Marco Trevisan (Treviño) Matcher: fix a typo, support gksu and gksudo as exec prefixes 2011-09-29 Marco Trevisan (Treviño) Matcher: use the environment desktop name to show or hide a desktop file If a desktop file has the OnlyShowIn or NotShowIn flag we use the defined XDG_CURRENT_DESKTOP variable to check if using or not that file in the current environment. 2011-11-29 Marco Trevisan (Treviño) libbamf doesn't actually notifies when a sticky application is opened or closed. This branch fixes the issue.. Fixes: . Reviewed by Didier Roche. 2011-11-23 Marco Trevisan (Treviño) libbamf: bamf-matcher, always notify an opened/closeview Don't consider if the view is sticky anymore. The client should care about this. 2011-11-29 Mikkel Kamstrup Erlandsen Bugfix: * Add missing guard checking if the legacy WnckWindow is != NULL in bamf_legacy_window_save_mini_icon(). This fixes the tests /Application/ManagesXid and /Application/Xids when running headless Fixes for headless test mode: * Properly exit if any tests report errors during 'make check' when running in headless mode * Remove debug spew when running tests "Export path: %s\n" * Remove unused variable TEST_RESULTS from test Makefile.ams. Fixes: . Reviewed by Didier Roche. 2011-11-29 Mikkel Kamstrup Erlandsen Remove unused variable TEST_RESULTS from test Makefile.ams 2011-11-29 Mikkel Kamstrup Erlandsen Remove debug spew when running tests "Export path: %s\n" 2011-11-29 Mikkel Kamstrup Erlandsen Add missing guard checking if the legacy WnckWindow is != NULL in bamf_legacy_window_save_mini_icon(). This fixes the tests /Application/ManagesXid and /Application/Xids 2011-11-28 Mikkel Kamstrup Erlandsen Run headless tests with 'set -e' to catch if our invaocation of 'make test' fails. Also don't use weird names for log files. 2011-11-28 Mikkel Kamstrup Erlandsen Fixes 'make check' and adds a headless testing mode that will be enabled if running configure with --enable-headless-tests=yes. Fixes: 897148,897150. Reviewed by Didier Roche. 2011-11-28 Mikkel Kamstrup Erlandsen Add a configure switch --enable-headless-tests that will cause 'make check' to run in headless mode. This requires the Xvfb and dbus-launch executables to be present on the system (which is checked for) 2011-11-28 Mikkel Kamstrup Erlandsen Remove what seems to be a copy-paste error from the test /Application/Events/WindowAdded which caused it to register the same dbus object twice in a row, causing the test to fail 2011-09-26 Didier Roche Releasing 0.2.104 2011-09-26 Didier Roche use the new API only with gtk3 wnck 2011-09-26 Didier Roche releasing 0.2.102 2011-09-22 Jason Smith fix webapps created through the wrench menu 2011-09-22 Jason Smith fix chromium webapp support 2011-09-13 Neil Jagdish Patel bamfdaemon crashed with SIGSEGV in sn_xcb_display_new() 2011-09-08 Neil Jagdish Patel [release] 0.2.98 2011-08-30 Marco Trevisan Merge bamf fixes branch 2011-06-27 Marco Trevisan (Treviño) compare_sub_values optimization. Generate the "prefix" string just once, and not for every sub-folder .desktop item compared. This should save many allocations/copies... 2011-06-22 Marco Trevisan (Treviño) Use some more "const char*" when possible... 2011-06-21 Marco Trevisan (Treviño) Some code spacing fixes... 2011-05-31 Marco Trevisan (Treviño) Give priority to .desktop files coming from the Desktop folder Always put the .desktop files coming from the user desktop folder as priority files, prepending them to the desktop file list. 2011-05-31 Marco Trevisan (Treviño) Correctly free non used strings, and don't double-check for list element Move out some memory leaks included in past commits. 2011-05-31 Marco Trevisan (Treviño) BAMF Application, reorder the desktop list The desktop file list passed by the matcher is ordered, but a BAMF application doesn't correctly use it, since it duplicates the list using the prepend function, without reversing it. This causes an inverted list. Plus, using g_list_free_full when the list was already initialized. 2011-05-31 Marco Trevisan (Treviño) Matcher: correctly order desktop files by priority. Desktop files whose name is equal to the desktop_id were prepended to the desktop file list, but this caused to reverse their priority (since the ones coming from a less prioritized directory were put before the ones coming from an high priority directory). Now the desktop files with a desktop_id matching name are inserted in a sorted way: they are appended to the other matching desktop files while they're really prepended to the list of the other desktop files. 2011-05-27 Marco Trevisan (Treviño) Bamf-application: correclty free wmclass / desktop file when replacing When replacing the desktop_class or wmclass parameter, free the previously set value. 2011-05-19 Marco Trevisan (Treviño) Include the G_USER_DIRECTORY_DESKTOP as .desktop repository With this the user desktop directory will be used as a .desktop files repository too (with the highest priority), also if BAMF won't include and monitor its subfolders (alredy there or added during the BAMF runtime). LP: #768636 2011-05-19 Marco Trevisan (Treviño) Include missing support for $XDG_DATA_HOME The $XDG_DATA_HOME env variable can be used to set data directories too. BAMF should support it. Added the utility function get_desktop_file_env_directories() to perform this task (and generalize the case). 2011-05-19 Marco Trevisan (Treviño) Use bamf_add_new_monitored_directory() To keep code cleaner, plus add some forgotten fixes. 2011-05-19 Marco Trevisan (Treviño) Correctly free / unref objects Some leak fixes in matcher... 2011-05-19 Marco Trevisan (Treviño) Matcher: recursively include new monitored subfolders. When adding a new folder into a monitored .desktop folder, that is scanned for its subfolders, and the BAMF desktop tables are updated using all the .desktop files found into this tree. To do that I've splitted the old create_desktop_file_table() introducing the new fill_desktop_file_table() and get_desktop_file_directories() adding get_directory_tree_list(). There are also other code improvements, the most important checks that the found subfolders are added in the proper order (keeping the priority and hierarchy). It includes also more comments on previous code, and uses G_DIR_SEPARATOR_S. 2011-05-10 Marco Trevisan (Treviño) Correctly remove the referenced desktop_files from HashTables BAMF currently uses HashTables which links lists of .desktop files, when a .desktop file has been (re)moved it should be un-referenced by these lists, by the way the current implementation didn't do that correctly. Checking for hashtable values (lists) and not for their subvalues (.desktop files). Of course, this fixes the leakage caused by not removing the desktop strings and/or the GList structs. Now it should be fixed. 2011-04-29 Marco Trevisan (Treviño) Don't allow to add duplicated list entries into the hashtables item for each desktop file. 2011-04-29 Marco Trevisan (Treviño) load_index_file_to_table: don't use GString for filename and free it The GString is useless here, and it wasn't free'd as needed. 2011-04-23 Marco Trevisan (Treviño) Set file monitor rate limit to 1sec Don't monitor desktop folders too often. Checking changes every sec should be enough. 2011-04-23 Marco Trevisan (Treviño) Support for monitoring changes to desktop directories Both support for added and removed directories from a .desktop directory. When a new subfolder is added, it must be monitored; when a desktop folder is removed it should be unmonitored. 2011-04-21 Marco Trevisan (Treviño) matcher: support for reloading informations of an edited desktop. When a desktop file has been edited, BAMF should reload its informations 2011-04-21 Marco Trevisan (Treviño) Fix support for new desktop files monitoring. Previous implementation (due a typo, I guess) was not checking the "new file" event. 2011-08-25 Neil Jagdish Patel [release] 0.2.96 2011-08-25 Neil Jagdish Patel [release] 0.2.94 2011-08-24 Jason Smith dont crash if someone frees memory we didn't mean to pass out 2011-08-01 Jason Smith merge gio removal branch 2011-08-01 Jason Smith more elegant 2011-08-01 Jason Smith remove accidental changes 2011-08-01 Jason Smith fix build errors with new toolchain 2011-08-01 Jason Smith remove gio patch 2011-08-01 Jason Smith remove GIO module 2011-08-01 Jason Smith implement upstream GIO signal handling 2011-06-17 Neil Jagdish Patel [release] 0.2.92 2011-06-09 Micheal Terry Merge gtk3 support branch 2011-05-31 Michael Terry first pass at gtk3 support 2011-04-27 Gord Allott respects the NoDisplay option in .desktop files - fixes lp:741129 2011-04-27 Gord Allott check for NoDisplay in desktop files before looking at them 2011-04-26 Jason Smith fix issue where already active windows didn't signal the state change 2011-04-21 Jason Smith Expand suffix regex to cover python 2011-04-19 Jason Smith remove printf 2011-04-19 Jason Smith account for -bin or .bin style launchers 2011-04-19 Didier Roche [release] 0.2.90 2011-04-18 Gord Allott Uses X-GNOME-FullName instead of the Name if its available 2011-04-18 Gord Allott used get_locale_string because for some reason, people speak a different language to me, crazy people... 2011-04-18 Gord Allott enables X-GNOME-FullName in bamfs name lookup, prefers if enabled 2011-04-18 Jason Smith merge fix for using window name vs class for unmatched windows 2011-04-18 Robert Ancell Use the first window name, not the first window class name for applications that don't have a .desktop file. Also remove dead code to set the name in bamf_application_child_added () - it is immediately overwritten in bamf_application_setup_icon_and_name (). 2011-04-15 Neil Jagdish Patel Send back a copied string 2011-04-14 Neil Jagdish Patel [release] 0.2.88 2011-04-12 Jason Smith make sure we dont fail to match because the WM class was different. Simply prefer matches based on wm-class 2011-04-11 Neil Jagdish Patel [release] 0.2.86 2011-04-08 Jason Smith dont export stable name based on wm-class. wm-class may be shared between multiple discrete apps and is not a valid way to provide a stable/unique name 2011-04-07 Neil Jagdish Patel [release] 0.2.84 2011-04-06 Jason Smith ensure we dont send bad windows out to dbus and crash 2011-04-06 Jason Smith ref_sink rather than ref so that when a floating view is set sticky it will destroy properly 2011-04-05 Neil Jagdish Patel Check what we actually want to check is valid, not what we know is invalid 2011-03-31 Neil Jagdish Patel [release] 0.2.82 2011-03-31 Jason Smith merge wm matching class work from Marco Trevisan 2011-03-29 Marco Trevisan (Treviño) Some code spaces cleanup. 2011-03-29 Marco Trevisan (Treviño) application_class renamed as application_wmclass To avoid gobjet get_class function overriding 2011-03-26 Marco Trevisan (Treviño) bamf-matcher: match desktop files by StartupWMClass Also consider matching desktop files the ones with the StartupWMClass equal to the window WMClass. 2011-03-26 Marco Trevisan (Treviño) bamf-matcher: check for matching desktop StartupWMClass and xwindow class When matching possible desktop applications for window, always check that the found desktop file has an unset StartupWMClass or a matching one (with the window's class). This allow to avoid that applications with same PIDs but with different WMClass are considered as the same application (fixes chromium applications issues). 2011-03-26 Marco Trevisan (Treviño) bamf-matcher: cache in a table the desktop StartupWMClass If a desktop file has a StartupWMClass field, then store it in cache, to use it for checking applications classes and match them with desktop files. 2011-03-26 Marco Trevisan (Treviño) bamf-matcher: application windows should share the same class Don't try to associate a window to an application if the window class differs from the application class. When initializing a bamf application, the class must be always set. 2011-03-26 Marco Trevisan (Treviño) bamf-application: support for class name property Now a bamf application can have also a class property. 2011-03-26 Marco Trevisan (Treviño) bamf-matcher: local applications are in ~/.local/share Previous implementation didn't grab any local desktop file installed since it was looking to them in $HOME/.share that is not a valid folder. 2011-03-31 Neil Jagdish Patel Protect against a NULL display returning 2011-03-17 Neil Jagdish Patel [release] 0.2.80 2011-03-16 Gord Allott fixes a bug in bamf sub-directory lookups, kde 4 apps now match fixes:693755 2011-03-15 Gord Allott fixes bamf loading subdirs from /usr/share/applications - lp:693755 2011-02-13 Neil Jagdish Patel Add a validity check for a returned View 2011-02-10 Didier Roche bump version 2011-02-10 Jason Smith fix tabs 2011-02-10 Martin Pitt fix tabs 2011-02-10 Jason Smith merge libreoffice fix from Martin Pitt 2011-02-10 Martin Pitt Update OO.o special case matching to also work for LibreOffice (LP: #705461) 2011-02-09 Jason Smith minor type fix 2011-01-27 Neil Jagdish Patel [release] 0.2.76 2011-01-26 Mirco Müller modified: lib/libbamf/bamf-view.c lib/libbamf/bamf-view.h src/bamf-view-glue.xml src/bamf-view.c src/bamf-view.h tests/functional/alt-tabber.c Merged bamf-branch add-name-changed-signal after review and approval from Jason. This adds the signal "name-changed" to the daemon and library so client-applications can hook up to a signal, if they want to be informed, if the title of a window (because of a tab-focus change) was altered. This is a prerequisite for fixing unity bug 691651. 2011-01-26 Mirco Müller free string of old name on the daemon-side 2011-01-26 Mirco Müller remove debugging-printf()s, make alt-tabber a bit nicer to look at, when titles update due to tab-focus-changes 2011-01-26 Mirco Müller use correct parameter-count also on libbamf-side for the name-changed signal 2011-01-26 Mirco Müller minor fixes 2011-01-26 Mirco Müller wrong count-number for signals parameters corrected 2011-01-26 Mirco Müller still trying to hook up to the name-changed signal to see if everything works as intended 2011-01-26 Mirco Müller corrected some errors on the libbamf-side for the new name-changed signal 2011-01-26 Mirco Müller adding name-changed signal also on client library side 2011-01-25 Mirco Müller Adding a name-changed signal to bamfdaemon 2011-01-20 Didier Roche releasing 0.2.74 2011-01-18 Didier Roche Set the default application icon when the application desktop file has no icon= key. It was appearing fully black. This fix bug #703521. 2011-01-15 Didier Roche Set the default application icon when the application desktop file has no icon= key. It was appearing fully black 2011-01-14 Neil Jagdish Patel [release] 0.2.72 2011-01-14 Neil Jagdish Patel [merge] ted's work 2011-01-14 Ted Gould Match the changing names in the approver 2011-01-14 Neil Jagdish Patel [release] 0.2.70 2011-01-14 Jason Smith make bamf use stable as possible naming 2010-12-17 Neil Jagdish Patel [release] 0.2.68 2010-12-11 Jason Smith use a weak ref to remove dead objects 2010-12-09 Neil Jagdish Patel [release] 0.2.66 2010-12-03 Didier Roche check that desktop file is currently supported before creating the favorite LP: #682345 2010-12-03 Didier Roche only RegisterFavorites if the desktop file is valid 2010-12-03 Didier Roche check that desktop file is currently supported before creating the favorite LP: #682345 2010-12-03 Jason Smith ensure we dont have an invalid reference to ourself after emitting the closed signal 2010-12-02 Jason Smith hopefully fix ref counting once and for all 2010-11-30 Neil Jagdish Patel [release] 0.2.64 2010-11-29 Jason Smith minor fixes for favorites handling 2010-11-18 Neil Jagdish Patel [release] 0.2.62 2010-11-18 Mikkel Kamstrup Erlandsen Final build-fiddling to make bamf work out-of-tree in jhbuild 2010-11-18 Mikkel Kamstrup Erlandsen Build fixes in order to work with jhbuild: * Require --enable-introspection=no in distcheck * Fix includes in bamf-tab.h * Fix include paths to also pick up the generated files in the build dir 2010-11-16 Jason Smith merge crash fix 2010-11-16 Jason Smith fix crash 2010-11-09 jassmith@gmail.com Ensure we dont emit signals after close 2010-11-11 Neil Jagdish Patel [release] 0.2.60 2010-11-05 Didier Roche fix DSO linking 2010-11-02 jassmith@gmail.com ensure we favorite applications over the bus as well 2010-11-01 jassmith@gmail.com improve favorites behavior (refcounting was failing) begin implementing suggested click behaviors 2010-10-25 jassmith@gmail.com add favorites support 2010-09-29 jassmith@gmail.com fix string in gio module 2010-09-27 jassmith@gmail.com dummy commit 2010-09-27 jassmith@gmail.com pre release increment 2010-09-27 jassmith@gmail.com ensure we dont mark windows user visible that are confusing to unity 2010-09-24 jassmith@gmail.com ensure we are pushing valid data 2010-09-22 jassmith@gmail.com merge favorites fixes 2010-09-22 jassmith@gmail.com Ensure that favorites export the proper icon and match up with newly added favorites 2010-09-22 jassmith@gmail.com Ensure we free tmp files and that we dont crash in malformed .desktop files 2010-09-22 Neil Jagdish Patel Post release bump 2010-09-22 Neil Jagdish Patel [release] 0.2.54 2010-09-21 jassmith@gmail.com Update to include convenience API for non-dock type consumers. Useful for consumers watching window change events not wishing to track closed signals for every object. 2010-09-16 Neil Jagdish Patel Post release bump 2010-09-16 Neil Jagdish Patel [release] 0.2.52 2010-09-15 jassmith@gmail.com Ensure we ship proper strings to open office windows 2010-09-15 Ken VanDine Release 0.2.50 2010-09-15 jassmith@gmail.com Initialize xid 2010-09-15 jassmith@gmail.com Undo yesterdays stupid 2010-09-14 jassmith@gmail.com Add extra caching 2010-09-14 jassmith@gmail.com merge pc file version branch 2010-09-14 Ted Gould Putting the proper version in the .pc file 2010-09-14 jassmith@gmail.com ensure we load .desktop files that are passed as favorites 2010-09-14 Neil Jagdish Patel post release bump 2010-09-14 Neil Jagdish Patel [release] 0.4.48 2010-09-13 jassmith@gmail.com pass back correct path on application for xid 2010-09-13 jassmith@gmail.com Change show_stubs to be show_menu_stubs 2010-09-13 jassmith@gmail.com merge application for window branch 2010-09-10 Ted Gould Add finding an application for a window we have. 2010-09-13 jassmith@gmail.com merge show-stubs branch 2010-09-10 Ted Gould Merge from trunk 2010-09-10 Ted Gould Fleshing out getting the show_stubs 2010-09-10 Ted Gould Putting in a stub show_stubs 2010-09-10 Ted Gould Whitespace 2010-09-10 Ted Gould Checking for the key in the desktop file. 2010-09-10 Ted Gould Switching the desktop file to be loaded from a keyfile so we can get other keys out 2010-09-10 Ted Gould Adding the show_stubs variable to the private structure 2010-09-10 Ted Gould Adding a show stubs function in the application. 2010-09-10 Ted Gould Adding a show stubs function to the dbus application interface 2010-09-13 jassmith@gmail.com fix registration 2010-09-13 jassmith@gmail.com ban dropbox from bamf 2010-09-09 Mikkel Kamstrup Erlandsen Post release version bump 2010-09-09 Mikkel Kamstrup Erlandsen Release 0.2.46 2010-09-09 jassmith@gmail.com merge in favorites branch 2010-09-09 jassmith@gmail.com fix up review requests by kamstrup 2010-09-08 jassmith@gmail.com remove debug statements 2010-09-08 jassmith@gmail.com Implement favorites registration client side 2010-09-08 jassmith@gmail.com add comment explaining matching order for multiple desktop files 2010-09-08 jassmith@gmail.com initial implementation of favorites 2010-09-01 Ted Gould Add get_windows to the library header 2010-08-31 Ted Gould Cut-and-paste error 2010-08-31 Ted Gould Adding the prototype to the header. 2010-08-31 jassmith@gmail.com add api for getting window list 2010-08-31 jassmith@gmail.com Add support to export the desktop window and marking window types 2010-08-19 Mikkel Kamstrup Erlandsen Post release version bump 2010-08-19 Mikkel Kamstrup Erlandsen Release 0.2.44 2010-08-19 Mikkel Kamstrup Erlandsen Merge Mikkel's branch lp:~unity-team/bamf/gio-api-bump: * Bump to new API/ABI for the GIO extension point 2010-08-18 Mikkel Kamstrup Erlandsen Update to latest GIO extension point API. See LP bug #616737 2010-08-19 jassmith@gmail.com use o for signature instead of s 2010-08-18 jassmith@gmail.com Add approver revise judgement api and disable approver by default 2010-08-18 jassmith@gmail.com Fix potential NULL deref when XDG_DATA_DIRS is not set 2010-08-12 Mikkel Kamstrup Erlandsen Post release version bump 2010-08-12 Mikkel Kamstrup Erlandsen Release 0.2.42 2010-08-11 jassmith@gmail.com fix timer and ensure tesets can run with improperly setup environment for MIR 2010-08-02 Mikkel Kamstrup Erlandsen Post release version bump 2010-08-02 Mikkel Kamstrup Erlandsen Release 0.2.40 2010-07-30 Neil Jagdish Patel Update some gtk-doc stuff to be explicit about ownership transfer 2010-07-22 Mikkel Kamstrup Erlandsen Post release version bump to 0.2.39 2010-07-22 Mikkel Kamstrup Erlandsen post release version bump to 0.2.38 2010-07-20 jassmith@gmail.com add notify signals 2010-07-20 jassmith@gmail.com fix issue where wrong signal was emitted on view removed 2010-07-16 Neil Jagdish Patel Bump to the next devel version 2010-07-16 Neil Jagdish Patel [release] 0.2.36 2010-07-13 jassmith@gmail.com implement code to re-register with remote service in case of crash 2010-07-13 jassmith@gmail.com whitespace 2010-07-13 jassmith@gmail.com ensure the view closed signal is the LAST signal fired that references that signal. This is important for the client lib as it will need to clean up its memory 2010-07-13 jassmith@gmail.com start work to clean up memory management 2010-07-12 jassmith@gmail.com re-disable warning message when bamf-factory gets an empty string as it has valid reasons for happening 2010-07-12 jassmith@gmail.com add caching of flags and fix minor logic error in item factory 2010-07-12 jassmith@gmail.com remove unneeded wnck reference 2010-07-12 jassmith@gmail.com more memory cleanups 2010-07-12 jassmith@gmail.com enforce const and improve caching in lib 2010-07-12 jassmith@gmail.com export properties over the bus for easier inspection and debugging using d-feet 2010-07-12 jassmith@gmail.com allow for grabbing of the remote dbus menu path 2010-07-12 jassmith@gmail.com print out indicators in alt-tabber test 2010-07-12 jassmith@gmail.com Add library implementation of indicator 2010-07-12 Neil Jagdish Patel Bump to next development release 2010-07-12 Neil Jagdish Patel Update ignores 2010-07-12 Neil Jagdish Patel [release] 0.2.34 2010-07-09 jassmith@gmail.com Unused defines 2010-07-09 jassmith@gmail.com migrate to API as provided by teds branch 2010-07-09 jassmith@gmail.com ensure proper setting of running state 2010-07-09 jassmith@gmail.com Add parents API to bus for debugging purposes 2010-07-09 jassmith@gmail.com properly dispose of indicators when they fall off the bus 2010-07-09 jassmith@gmail.com major overhaul of how indicators are handled modified api for closing views to removing disposal magic updated tests to reflect new api 2010-07-06 jassmith@gmail.com delete code that was meant to be deleted long ago 2010-07-06 Jason Smith missing header 2010-07-02 Jason Smith Allow legacy windows to save their mini icons to a file for fallback purposes 2010-07-02 Jason Smith line swap 2010-07-02 Jason Smith fix test building 2010-07-02 Jason Smith Make sure to send back a proper approve signal 2010-07-02 Jason Smith finish up matching work on indicators 2010-07-01 Jason Smith initial implementation of indicator approver service 2010-06-24 Neil Jagdish Patel Bump to next development version 2010-06-24 Neil Jagdish Patel [release] 0.2.32 2010-06-24 Jason Smith fix potential crash from junk data 2010-06-18 Jason Smith Check on process name if no matches are found (fixes exaile) 2010-06-17 Jason Smith better oo.o matching 2010-06-17 Neil Jagdish Patel bump for next devel release 2010-06-17 Neil Jagdish Patel [release] 0.2.30 2010-06-17 Jason Smith ensure we recurse into directories 2010-06-14 Jason Smith Add bamf_window_last_active to BamfWindow in client library. Backend modifications required for situations where applications start up after window has opened. 2010-06-14 Jason Smith merge el trunko 2010-06-10 Neil Jagdish Patel Bump to next devel version 2010-06-10 Neil Jagdish Patel [release] 0.2.28 2010-06-14 Jason Smith initial import for tab class into client library 2010-06-11 Jason Smith perform wild ass guess for transient windows. It should be relatively harmless. 2010-06-11 Jason Smith setup parent list 2010-06-11 Jason Smith remove bamf_view_get_parent as its intended for internal use only 2010-06-11 Jason Smith Add call to client library for checking transients 2010-06-11 Jason Smith add transient window property to bus 2010-06-07 Jason Smith merge anjali bamf 2010-06-07 Jason Smith Up release number for new build 2010-06-07 Jason Smith Ensure we don't try to get empty paths 2010-06-04 Neil Jagdish Patel Bump to next development release 2010-06-04 Neil Jagdish Patel [release] 0.2.26 2010-06-03 Neil Jagdish Patel Make sure to send back a dupped string, otherwise you crash 2010-06-02 Jason Smith Use more descript marshaller 2010-06-02 Jason Smith more updates for Maverick 2010-06-02 Jason Smith fix the first of many new issues in maverick 2010-06-02 Mikkel Kamstrup Erlandsen Merge Mikkel's branch lp:~anjali-team/anjali/bamf.gtk-doc * Adds gtk-doc support for libbamf * Fixes distcheck 2010-06-02 Mikkel Kamstrup Erlandsen Distcheck passing. w00t! Add missing AC_SUBST(DBUS_LIBS) and AC_SUBST(DBUS_CFLAGS) to configure.in. How bamf ever compiled without these are beyond me. Don't install bamf-tab-source-glue.h and bamf-marshal.h as library headers (they are autgenerated impl details) Don't use libtool to generate the dbus-glib marshalling code 2010-06-01 Mikkel Kamstrup Erlandsen Add --enable-gtk-doc to DISTCHECK_CONFIGURE_FLAGS 2010-06-01 Mikkel Kamstrup Erlandsen GTK-DOC generation working 2010-06-01 Mikkel Kamstrup Erlandsen Add initial infrastructure for gtk-doc support 2010-05-28 Jason Smith remove cruft 2010-05-28 Jason Smith merge bamf public branch 2010-05-28 Jason Smith merge in changes from neil 2010-05-27 Jason Smith add monitors to file directories 2010-05-27 Jason Smith follow XDG specification on .desktop file locations 2010-05-27 Jason Smith move creation of list of directories to unique method for usage later 2010-05-26 Jason Smith more chromium cruft 2010-05-26 Jason Smith remove outdated chrome app hacks 2010-05-26 Jason Smith fix bamf_legacy_window_is_desktop call 2010-05-26 Jason Smith Properly group unmatched windows. Even in hopeless matching conditions. 2010-05-26 Jason Smith Ensure we properly set icon names and view names for applications 2010-05-27 Neil Jagdish Patel Bump to next development version 2010-05-27 Neil Jagdish Patel [release] 0.2.24 2010-05-27 Neil Jagdish Patel Check if GAppInfo is valid 2010-05-27 Neil Jagdish Patel - For non-desktop-file-backed applications, get some of the applications properties from the first child that's added 2010-05-26 Jason Smith update filter to ensure we dont get stray events 2010-05-26 Jason Smith hook up signals properly 2010-05-26 Jason Smith properly set name 2010-05-26 Jason Smith Avoid double freeing memory in certain conditions 2010-05-26 Gord Allott added introspection.m4 so that we can build without gobject-introspection 2010-05-25 Neil Jagdish Patel Remove useless marshal.[h|c] 2010-05-25 Neil Jagdish Patel Update copyright again so licensecheck can detect it 2010-05-25 Neil Jagdish Patel [release] 0.2.22 2010-05-25 Neil Jagdish Patel Add LGPL-2.1 COPYING 2010-05-25 Neil Jagdish Patel - Update Copyright to correct year modified: lib/libbamf/bamf-application.c lib/libbamf/bamf-application.h lib/libbamf/bamf-control.c lib/libbamf/bamf-control.h lib/libbamf/bamf-factory.c lib/libbamf/bamf-factory.h lib/libbamf/bamf-matcher.c lib/libbamf/bamf-matcher.h lib/libbamf/bamf-tab-source.c lib/libbamf/bamf-tab-source.h lib/libbamf/bamf-view.c lib/libbamf/bamf-view.h lib/libbamf/bamf-window.c lib/libbamf/bamf-window.h lib/libbamf/libbamf.h lib/libbamf/marshal.c lib/libbamf/marshal.h src/bamf-application.c src/bamf-application.h src/bamf-control.c src/bamf-control.h src/bamf-legacy-screen.c src/bamf-legacy-screen.h src/bamf-legacy-window-test.c src/bamf-legacy-window-test.h src/bamf-legacy-window.c src/bamf-legacy-window.h src/bamf-matcher.c src/bamf-matcher.h src/bamf-tab-source.c src/bamf-tab-source.h src/bamf-tab.c src/bamf-tab.h src/bamf-view.c src/bamf-view.h src/bamf-window.c src/bamf-window.h src/bamf.h src/main.c src/main.h 2010-05-25 Neil Jagdish Patel Update Copyright for bamfdaemon 2010-05-25 Neil Jagdish Patel Fix Copyright in libbamf 2010-05-25 Didier Roche remove wrong extra_dist target in Makefile.am 2010-05-19 Jason Smith make plugin actually load inside of chromium, it does not do much yet but it is getting there! 2010-05-19 Jason Smith Add introductory work on chromium plugin 2010-05-19 Jason Smith More work in tab integration, tabs items should now be created properly but are not exported or matched 2010-05-19 Jason Smith fix sending the wrong item in remove signals 2010-05-19 Jason Smith Hookup Active Application and Active Window change signals in matcher 2010-05-18 Jason Smith add tests for Active event in BamfWindow and BamfApplication to ensure events are properly triggered 2010-05-18 Jason Smith move code around to be more GObject friendly 2010-05-18 Jason Smith ensure active signal is properly bubbled by children of applications instead of doing manual checks 2010-05-18 Jason Smith Ensure unit tests pass and add API for tedder Add ActiveWindowChanged signal Add ActiveApplicationChanged signal Add ActiveApplication call Add ActiveWindow call 2010-05-18 Jason Smith export more of the tab interface 2010-05-18 Jason Smith start hooking up signals for tab management 2010-05-18 Jason Smith Added: src/bamf-tab-glue.xml : API Glue src/bamf-tab.c : Tab class src/bamf-tab.h : Tab class header tests/functional/tab-source-test.c : First and simplest possible functional test of remote tab registration modified: lib/libbamf/bamf-tab-source.c : Finish out base class, consumers will need to subclass lib/libbamf/libbamf.h : Add tab source header src/Makefile.am : Update with new files src/bamf-control.c : Add support for creating new remote tab sources src/bamf-tab-source.c : Make this kind of start to work as designed src/bamf-view.c : Add a check to prevent double close signals tests/functional/Makefile.am : Update for new test 2010-05-18 Jason Smith missing test 2010-05-18 Jason Smith typo 2010-05-18 Jason Smith Missing file 2010-05-18 Jason Smith make build 2010-05-18 Jason Smith missing files 2010-05-18 Jason Smith API updates 2010-05-12 Jason Smith Ensure we unhook dbus events 2010-05-12 Jason Smith ensure you can fetch xid from bamf-window 2010-05-12 Jason Smith remove spare items from signal enum 2010-05-12 Jason Smith Migrate is_urgent into bamf-view classes 2010-05-12 Jason Smith Migrate user visible into bamf-view, ensuring not to break unit tests 2010-05-12 Jason Smith White space fixes 2010-05-12 Jason Smith removed: tests/bamfdaemon/test-mock-window.ca : use mock windows in bamf daemon instead tests/bamfdaemon/test-mock-window.h modified: module/dbus-module.c : Track depends module/gapplaunchhandlerdbus.c : Ensure we dont conflict with wncksync module/gapplaunchhandlerdbus.h src/bamf-legacy-screen.c : Update screen handling of state files src/bamf-tab-source.c : Get ready to consume dbus objects src/simple-state.txt : Slightly more complex to fully test out file format tests/bamfdaemon/Makefile.am tests/bamfdaemon/test-application.c : Properly use daemon mock objects 2010-05-10 Jason Smith make loading from file accept an exec string. This promotes a lot more realistic interaction 2010-05-10 Jason Smith start adding tab source crap 2010-05-09 Jason Smith migrate bamf-daemon to using generated marshallers 2010-05-07 Jason Smith add example state file 2010-05-07 Jason Smith add support for loading state from file 2010-05-07 Jason Smith Add unit tests for bamf window 2010-05-07 Jason Smith add icon support to libbamf 2010-05-07 Jason Smith add support for getting an icon 2010-05-07 Jason Smith allow bamf view to be subclassed on the client side 2010-05-07 Jason Smith Add ending squigly line 2010-05-07 Jason Smith Add default values for failed calls 2010-05-07 Jason Smith test events and visiblity fully 2010-05-07 Jason Smith remove extra includes 2010-05-07 Jason Smith implement bamf legacy stuff 2010-05-06 Jason Smith fix build 2010-05-06 Jason Smith start work on interaction tester and ignore DESKTOP windows 2010-05-06 Jason Smith fix single in factory class 2010-05-06 Jason Smith add missing signals 2010-05-06 Jason Smith stuff gord did 2010-05-06 Jason Smith remove wnck from build 2010-05-06 Jason Smith make sure that all our signals fire properly 2010-05-06 Jason Smith Make flag events fire properly 2010-05-06 Jason Smith Bind "Xids" dbus call 2010-05-06 Jason Smith Add methods for checking user visible 2010-05-06 Jason Smith Add methods to check if things are user visible and test into functional tests 2010-05-06 Jason Smith remove stray wnck crap 2010-05-06 Jason Smith fix build 2010-05-06 Jason Smith more hatred of wnck 2010-05-06 Jason Smith make .pc define WNCK_I_KNOW_THIS_IS_UNSTABLE 2010-05-06 Jason Smith more documentation 2010-05-06 Jason Smith fix typos 2010-05-06 Jason Smith add documentation 2010-05-06 Jason Smith spelling 2010-05-06 Jason Smith add docs to bamf-window 2010-05-06 Jason Smith add docs to bamf-view.h 2010-05-06 Jason Smith Update gio module strings 2010-05-06 Jason Smith Update doc 2010-05-06 Jason Smith fix GIR namespace 2010-05-06 Jason Smith test out new comment structure in bamf-view 2010-05-06 Jason Smith implement RunningApplications 2010-05-06 Jason Smith clean up new () function 2010-05-06 Jason Smith clean up constructors further 2010-05-06 Jason Smith cleanup constructor in bamf-application 2010-05-06 Jason Smith Clean up new function in bamf-window 2010-05-06 Jason Smith Remove legacy files from bamf daemon 2010-05-06 Jason Smith Remove legacy source files from libbamf 2010-05-06 Jason Smith merge vapi branch 2010-05-05 Gordon Allott merged latest bamf 2010-05-05 Gordon Allott adds awesome vapi support and gir building 2010-05-05 Jason Smith add test framework for libbamf... no tests 2010-05-05 Jason Smith Make things build 2010-05-05 Jason Smith missing files 2010-05-05 Jason Smith add unit testing into get_xids call 2010-05-05 Jason Smith Add missing files 2010-05-05 Jason Smith Start next unit test, for some reason G_DEFINE_TYPE is not working in this file yet... 2010-05-05 Jason Smith More application unit tests 2010-05-05 Jason Smith add application unit test file 2010-05-05 Jason Smith add unit tests 2010-05-05 Jason Smith Move tests into subdirectory 2010-05-04 Jason Smith almost no memory leaks 2010-05-04 Jason Smith memory leak fixes 2010-05-04 Jason Smith Update for memory leaks 2010-05-04 Jason Smith add signals into bamf-view 2010-05-04 Jason Smith Add signals into bamf-applicaiton.c 2010-05-04 Jason Smith fix crash from null referencing 2010-05-04 Jason Smith remove debug 2010-05-04 Jason Smith Ensure we dont have errors exporting objects 2010-05-04 Jason Smith Fix bug where applications never left the bus 2010-05-04 Jason Smith Update demo and client lib. demo not working fully yet and client lib not fully completed 2010-05-03 Jason Smith Start work on client library 2010-05-03 Jason Smith General source and header cleanup 2010-05-03 Jason Smith saner API 2010-05-02 Jason Smith Fix typo and ensure that views deparent on closing 2010-05-02 Jason Smith remove extra GList from application 2010-05-02 Jason Smith Make active window tracking work 2010-05-02 Jason Smith Make applicaiton and matcher 90% functional 2010-05-02 Jason Smith lots of work, things largely starting to work at this point 2010-04-29 Jason Smith remove runtime warnings 2010-04-29 Jason Smith Merge el trunko 2010-04-28 Neil Jagdish Patel - Add missing G_END_DECLS modified: lib/libbamf/bamf-application.h lib/libbamf/bamf-control.h lib/libbamf/bamf-matcher.h lib/libbamf/bamf-view.h 2010-04-28 Neil Jagdish Patel - Add function stubs - Add control functions added: lib/libbamf/bamf-control.c modified: .bzrignore lib/libbamf/Makefile.am lib/libbamf/bamf-application.c lib/libbamf/bamf-control.h lib/libbamf/bamf-matcher.c lib/libbamf/bamf-view.c 2010-04-28 Neil Jagdish Patel Add bamf-matcher.c, bamf-view.c and bamf-application.c stubs. Things compile! added: lib/libbamf/bamf-matcher.c lib/libbamf/bamf-view.c modified: .bzrignore lib/libbamf/Makefile.am lib/libbamf/bamf-application.c lib/libbamf/bamf-application.h lib/libbamf/bamf-matcher.h lib/libbamf/bamf-proxy.c lib/libbamf/bamf-view.h 2010-04-27 Neil Jagdish Patel Remove libbamf.c (in bamf-proxy now) and make libbamf.h a single-include header like normal removed: lib/libbamf/libbamf.c modified: lib/libbamf/Makefile.am lib/libbamf/libbamf.h unknown: lib/libbamf/libbamf.la lib/libbamf/libbamf.pc lib/libbamf/libbamf_la-bamf-proxy.lo src/bamfdbus-glue.h 2010-04-27 Neil Jagdish Patel Move some stuff in libbamf => BamfProxy added: lib/libbamf/bamf-proxy.c lib/libbamf/bamf-proxy.h modified: lib/libbamf/Makefile.am 2010-04-29 Jason Smith Make build and kind of start running, huzzah! 2010-04-28 Jason Smith forgot to add bamf.h [as fortold by the prophetic email] 2010-04-27 Jason Smith builds at long last. feature severely incomplete 2010-04-27 Jason Smith build fixes 2010-04-27 Jason Smith more build fixes 2010-04-27 Jason Smith build system progress 2010-04-27 Jason Smith minor change 2010-04-27 Jason Smith add headers for libbamf 2010-04-26 Jason Smith fill in methods for bamf-application 2010-04-26 Jason Smith More work on application, matching API 2010-04-26 Jason Smith More work on bamf restructure 2010-04-23 Jason Smith Add new source files and update bamf naming 2010-03-31 Jason Smith Avoid junking our hashtable 2010-03-29 Neil Jagdish Patel [release] 0.2.20 2010-03-25 Jason Smith Merge prefer desktop-id branch 2010-03-25 Jason Smith Prefer .desktop files whose exec string is their desktop-id 2010-03-19 Jason Smith Better fix for previous commit 2010-03-19 Jason Smith Ensure matching state is preserved across runs by re-reading in existing desktop file hints. Useful for several things, mostly crash recovery. Also includes minor memory leak fix. 2010-03-18 Neil Jagdish Patel [release] 0.2.18 2010-03-12 Jason Smith Catch and ignore X errors 2010-03-12 Neil Jagdish Patel bump version for new dailys 2010-03-12 Jason Smith Merge async API branch 2010-03-12 Jason Smith add async checking of xid arrays 2010-03-11 Jason Smith Async API working for fetching of desktop files 2010-03-11 Neil Jagdish Patel [release] 0.2.16 2010-03-11 Jason Smith Merge gobject branch 2010-03-11 Jason Smith gobject-ize libwncksync 2010-03-04 Jason Smith minor memory leak fix cleanups to make hunting crashers easier 2010-03-04 Neil Jagdish Patel [release] 0.2.14 2010-02-26 Jason Smith Ensure we dont match onto terminals we launched from 2010-02-26 Neil Jagdish Patel [release] 0.2.12 2010-02-25 Jason Smith Remove gmenu and use wncksync caches instead 2010-02-25 Neil Jagdish Patel [release] 0.2.11 2010-02-25 Neil Jagdish Patel Add needed stuff to EXTRA_DIST 2010-02-23 Jason Smith Add robustness to chromium application matching 2010-02-20 Jason Smith Add matching based on desktop_id as GNOME is currently making a push to try to make this viable 2010-02-18 Neil Jagdish Patel [release] 0.2.10 2010-02-17 Jason Smith Merge matcher upgrade branch 2010-02-17 Jason Smith Dont crash on chromium apps 2010-02-17 Jason Smith rewrite large parts of window matcher to make it better architectured moving forward 2010-02-02 Jason Smith Format according to GNU standards 2010-01-26 Jason Smith Fix distcheck 2010-01-26 Jason Smith Increment version 2010-01-26 Jason Smith Make .service file work right 2010-01-26 Jason Smith Actually merge in Martin Pitt's branch. 2010-01-21 Martin Pitt disable profiling again 2010-01-21 Martin Pitt use gnome-menus instead of reading desktop files directly This gives us the caching of gnome-menus and thus avoids opening hundreds of desktop files and gettext .mo files. It also avoids looking at desktop files which are not displayed, or not an application. 2010-01-21 Martin Pitt add profiling support and benchmark create_desktop_file_table() 2010-01-20 Neil Jagdish Patel - Merge from upstream - Bump version to 0.2.4 renamed: examples/ => tests/ modified: Makefile.am configure.in tests/alt-tabber.c tests/desktop-file-launcher.c pending merges: Jason Smith 2010-01-19 Fix copyright in examples/ 2010-01-19 Jason Smith Fix copyright in examples/ Move examples/ to tests/ Change name from wncksyncdaemon to wncksync 2010-01-18 Neil Jagdish Patel [release] 0.2.2 -- more licensing fixes 2010-01-18 Neil Jagdish Patel [release] 0.2.1 2010-01-18 Neil Jagdish Patel [copyright] Add LGPL license, license lib/ as LGPL and re-license model/ as LGPL (so it can be safely used with gio and non-gpl programs that use glib) added: COPYING.LGPL modified: lib/libwncksync/libwncksync.c lib/libwncksync/libwncksync.h module/dbus-module.c module/gapplaunchhandlerdbus.c module/gapplaunchhandlerdbus.h 2010-01-14 Jason Smith Fix errors in merging 2010-01-14 Jason Smith Merge branch to make distcheck work 2009-11-17 Robert Collins Finished getting distcheck to work: Do not ship files that are always rebuilt, clean them during distclean, and honour DESTDIR for test installs. 2009-11-17 Robert Collins Use correct prefix handling for data/ and don't reimplement the configure sed magick in data/Makefile.am. 2009-11-17 Robert Collins Cleanup build warnings, dead code, mismatched types. 2009-10-31 Neil Jagdish Patel [ignores] Update added: .bzrignore 2009-10-31 Neil Jagdish Patel [build] Removed mono deps to make building packages a 'lil easier removed: WindowSwitcher/ WindowSwitcher/LibWnckSync/ WindowSwitcher/LibWnckSync/AssemblyInfo.cs WindowSwitcher/LibWnckSync/Global.cs WindowSwitcher/LibWnckSync/LibWnckSync.csproj WindowSwitcher/LibWnckSync/Makefile.am WindowSwitcher/Makefile.am WindowSwitcher/WindowSwitcher/ WindowSwitcher/WindowSwitcher.sln WindowSwitcher/WindowSwitcher/CairoContext_Extensions.cs WindowSwitcher/WindowSwitcher/GtkWidget_Extensions.cs WindowSwitcher/WindowSwitcher/Makefile.am WindowSwitcher/WindowSwitcher/Resources/ WindowSwitcher/WindowSwitcher/Resources/reflection.png WindowSwitcher/WindowSwitcher/Resources/reflectionA.png WindowSwitcher/WindowSwitcher/SwitcherArea.cs WindowSwitcher/WindowSwitcher/WindowSwitcher.cs WindowSwitcher/WindowSwitcher/WindowSwitcher.csproj WindowSwitcher/WindowSwitcher/WindowSwitcher.exe.config.in WindowSwitcher/WindowSwitcher/XKeybinder.cs WindowSwitcher/WindowSwitcher/window-switcher.in WindowSwitcher/libwsbind/ WindowSwitcher/libwsbind/Makefile.am WindowSwitcher/libwsbind/eggaccelerators.c WindowSwitcher/libwsbind/eggaccelerators.h WindowSwitcher/libwsbind/keybinder.c WindowSwitcher/libwsbind/keybinder.h m4/mono-nunit.m4 m4/mono.m4 m4/monodoc.m4 modified: Makefile.am configure.in src/wncksyncdbus-glue.h 2009-11-09 Jason Smith Fix build and add dbus method 2009-11-09 Jason Smith src/windowmatcher.c : add window_matcher_is_match_ready to help with open office window matching 2009-11-06 Jason Smith Remove mono dust 2009-11-06 Jason Smith Rename gio module to libgiowncksync 2009-11-06 Jason Smith Kill window switcher 2009-10-30 Jason Smith Xid's are defined as gulong by libwnck however they are defined by xorg as uint32, we will use uint32 instead of gulong. 2009-10-17 Jason Smith Don't crash 2009-10-17 Jason Smith Update patch 2009-10-17 Jason Smith Update gio patch to build properly 2009-08-07 Jason Smith loosen requirements for mono gmcs 2009-08-05 Jason Smith Add reflection, modify source to use 2009-08-04 Jason Smith remove debugging statement 2009-08-04 Jason Smith potential crasher 2009-08-04 Jason Smith update naming 2009-08-03 Jason Smith fix crash 2009-08-03 Jason Smith Patch from neil 2009-08-03 Jason Smith Modify behavior of window switcher to be more consistent. Super+Tab now switcher applications. Super+` switches windows within an application. Arrows also work 2009-08-02 Jason Smith Improve appearance 2009-08-02 Jason Smith fix build, improve behavior of switcher with multiple windows 2009-08-02 Jason Smith Bug fixes and deal with large numbers of windows 2009-08-02 Jason Smith finish out build system for mono example 2009-08-02 Jason Smith Fix infinite loop Allow building of mono based solutions 2009-08-01 Jason Smith Add m4 2009-08-01 Jason Smith Work on build system, fix build issue 2009-08-01 Jason Smith Add custom keybinder 2009-07-31 Jason Smith Improvements to window switcher program 2009-07-31 Jason Smith SwitcherArea.cs: Dont switch windows until key up windowmatcher.c: minor cleanup 2009-07-30 Jason Smith memory leak 2009-07-29 Jason Smith Make pretty with crash recovery 2009-07-29 Jason Smith Update patch, remove URI support from windowmatcher.c 2009-07-29 Jason Smith Update TODO 2009-07-29 Jason Smith Remove writeline 2009-07-29 Jason Smith add new keybinding 2009-07-29 Jason Smith Add WindowSwitcher demo 2009-07-28 Jason Smith Remove libwnck build dep 2009-07-28 Jason Smith Remove libwnck from header 2009-07-28 Jason Smith Remove all libwnck'ing from libwncksync 2009-07-28 Jason Smith Fix fencepost error in window matcher Change api of libwncksync to make it easier to bind against 2009-07-27 Jason Smith update patch 2009-07-27 Jason Smith Add patch 2009-07-27 Jason Smith Deal with file:// prefixes 2009-07-27 Jason Smith unique names 2009-07-27 Jason Smith Polish 2009-07-27 Jason Smith fix up header file and pkg-config file 2009-07-23 Jason Smith Fix matching of open office to work with newly opened windows 2009-07-23 Jason Smith reinstate call to process_exec_string that was removed by accident 2009-07-23 Jason Smith dont free wrong thing 2009-07-23 Jason Smith start working on ooffice stuff 2009-07-23 Jason Smith Add missing function to libwncksync 2009-07-23 Jason Smith Add TODO 2009-07-22 Jason Smith Update makefile 2009-07-21 Jason Smith fix bugs 2009-07-21 Jason Smith Add testing program for GIO module 2009-07-21 Jason Smith Update GIO patch 2009-07-21 Jason Smith Add gio patch 2009-07-21 Jason Smith Add first run at gio module for patched gio 2009-07-21 Jason Smith Add quit handler 2009-07-21 Jason Smith cleanup api to not use XID's 2009-07-21 Jason Smith add data dir 2009-07-21 Jason Smith finish up example program 2009-07-20 Jason Smith Fix compile 2009-07-20 Jason Smith fix Requires line 2009-07-20 Jason Smith Cleanup 2009-07-20 Jason Smith Add .pc.in file 2009-07-20 Jason Smith Add start of examples dir and autofoo to match 2009-07-17 Jason Smith Autogen foo 2009-07-16 Jason Smith At last 2009-07-16 Jason Smith Another intermediate 2009-07-16 Jason Smith halfway commit 2009-07-16 Jason Smith remove useless files 2009-07-16 Jason Smith Re-orginize 2009-07-16 Jason Smith Remove C# code 2009-07-16 Jason Smith Implement pid registration 2009-07-13 Jason Smith objectify windowmatcher 2009-07-13 Jason Smith Add C implentation of daemon 2009-07-07 Jason Smith Update libwncksync, works cleanly now for fetching .desktop files from xid 2009-07-07 Jason Smith Update naming 2009-07-07 Jason Smith Rename files 2009-07-07 Jason Smith Basic implementation 2009-07-07 Jason Smith Add shell of libwncksync C lib 2009-07-07 Jason Smith Add autotools 2009-07-07 Jason Smith Cast properly 2009-07-07 Jason Smith initial import ./lib/0000755000004100000410000000000014203512426012010 5ustar www-datawww-data./lib/libbamf-private/0000755000004100000410000000000014203512426015054 5ustar www-datawww-data./lib/libbamf-private/bamf-private.h0000644000004100000410000000270614203512426017607 0ustar www-datawww-data/* * Copyright (C) 2011-2013 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef __BAMF_PRIVATE_H__ #define __BAMF_PRIVATE_H__ #include #include #define BAMF_DBUS_SERVICE_NAME (g_getenv ("BAMF_TEST_MODE") ? "org.ayatana.bamf.Test" : "org.ayatana.bamf") #define BAMF_DBUS_BASE_PATH "/org/ayatana/bamf" #define BAMF_DBUS_CONTROL_PATH BAMF_DBUS_BASE_PATH"/control" #define BAMF_DBUS_MATCHER_PATH BAMF_DBUS_BASE_PATH"/matcher" #define BAMF_DBUS_DEFAULT_TIMEOUT 500 #define BAMF_DEFAULT_ICON_SIZE 128 #define BAMF_DEFAULT_MINI_ICON_SIZE 24 /* GLib doesn't provide this by default */ #ifndef G_KEY_FILE_DESKTOP_KEY_FULLNAME #define G_KEY_FILE_DESKTOP_KEY_FULLNAME "X-GNOME-FullName" #endif #define BAMF_APPLICATION_DEFAULT_ICON "application-default-icon" #endif ./lib/libbamf-private/org.ayatana.bamf.view.xml0000644000004100000410000001334714203512426021667 0ustar www-datawww-data ./lib/libbamf-private/Makefile.am.notparallel0000644000004100000410000000132014203512426021420 0ustar www-datawww-data.NOTPARALLEL: bamf-gdbus-generated.c: org.ayatana.bamf.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --generate-c-code $(shell basename $@ .c) \ --c-namespace BamfDBus \ --interface-prefix org.ayatana.bamf \ $<; \ # Adding '_' prefix to generated private functions \ $(SED) "s/bamf_dbus/_bamf_dbus/g" -i \ $@ $(shell basename $@ .c).h .NOTPARALLEL: bamf-gdbus-view-generated.c: org.ayatana.bamf.view.xml $(AM_V_GEN) $(GDBUS_CODEGEN) \ --c-generate-object-manager \ --generate-c-code $(shell basename $@ .c) \ --c-namespace BamfDBusItem \ --interface-prefix org.ayatana.bamf \ $<; \ # Adding '_' prefix to generated private functions \ $(SED) "s/bamf_dbus_item/_bamf_dbus_item/g" -i \ $@ $(shell basename $@ .c).h ./lib/libbamf-private/org.ayatana.bamf.xml0000644000004100000410000000625114203512426020712 0ustar www-datawww-data ./lib/libbamf-private/Makefile.am0000644000004100000410000000155114203512426017112 0ustar www-datawww-datainclude Makefile.am.notparallel noinst_LTLIBRARIES = libbamf-private.la bamf_gdbus_files = \ bamf-gdbus-generated.c \ bamf-gdbus-generated.h \ bamf-gdbus-view-generated.c \ bamf-gdbus-view-generated.h \ $(NULL) bamf_xml_gdbus_files = \ org.ayatana.bamf.xml \ org.ayatana.bamf.view.xml \ $(NULL) bamf_built_sources = \ $(bamf_gdbus_files) \ $(NULL) libbamf_private_la_CFLAGS = \ $(GLIB_CFLAGS) \ $(NULL) libbamf_private_la_LDFLAGS = \ -no-undefined \ $(NULL) libbamf_private_la_LIBADD = \ $(GLIB_LIBS) \ $(NULL) libbamf_private_la_SOURCES = \ bamf-private.h \ $(NULL) nodist_libbamf_private_la_SOURCES = \ $(bamf_built_sources) \ $(NULL) CLEANFILES = \ $(bamf_built_sources) \ $(NULL) DISTCLEANFILES = \ $(bamf_built_sources) \ $(NULL) BUILT_SOURCES = \ $(bamf_gdbus_files) \ $(NULL) EXTRA_DIST = \ $(bamf_xml_gdbus_files) \ $(NULL) ./lib/libbamf/0000755000004100000410000000000014203512426013404 5ustar www-datawww-data./lib/libbamf/bamf-application-private.h0000644000004100000410000000175414203512426020442 0ustar www-datawww-data/* * bamf-application-private.h * This file is part of BAMF * * Copyright (C) 2012 - Marco Trevisan (Treviño) * * BAMF 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. * * BAMF 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 BAMF; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA */ #ifndef _BAMF_APPLICATION_PRIVATE_H_ #define _BAMF_APPLICATION_PRIVATE_H_ #include GList * _bamf_application_get_cached_xids (BamfApplication *app); #endif ./lib/libbamf/bamf-tab.c0000644000004100000410000002472214203512426015230 0ustar www-datawww-data/* * Copyright 2010-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith Robert Carr * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include #include "bamf-tab.h" #include "bamf-view-private.h" enum { PROP_0, PROP_LOCATION, PROP_DESKTOP_ID, PROP_XID, PROP_IS_FOREGROUND_TAB }; typedef struct _BamfTabPrivate { BamfDBusItemTab *proxy; } BamfTabPrivate; static void bamf_tab_unset_proxy (BamfTab *self); G_DEFINE_TYPE_WITH_PRIVATE (BamfTab, bamf_tab, BAMF_TYPE_VIEW); static void on_proxy_property_change (GObject *gobject, GParamSpec *pspec, gpointer user_data) { BamfTab *self = BAMF_TAB (user_data); if (g_object_class_find_property (G_OBJECT_GET_CLASS (self), pspec->name)) g_object_notify (G_OBJECT (self), pspec->name); } static void bamf_tab_set_path (BamfView *view, const gchar *path) { BamfTab *self; BamfTabPrivate *priv; GError *error = NULL; self = BAMF_TAB (view); priv = bamf_tab_get_instance_private (self); bamf_tab_unset_proxy (self); priv->proxy = _bamf_dbus_item_tab_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, BAMF_DBUS_SERVICE_NAME, path, CANCELLABLE (view), &error); if (!G_IS_DBUS_PROXY (priv->proxy)) { g_error ("Unable to get %s tab: %s", BAMF_DBUS_SERVICE_NAME, error ? error->message : ""); g_error_free (error); return; } g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (priv->proxy), BAMF_DBUS_DEFAULT_TIMEOUT); g_signal_connect (priv->proxy, "notify", G_CALLBACK (on_proxy_property_change), self); } static void bamf_tab_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { BamfTab *self = BAMF_TAB (object); BamfTabPrivate *priv = bamf_tab_get_instance_private (self); if (!_bamf_view_remote_ready (BAMF_VIEW (self))) { G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); return; } switch (property_id) { case PROP_LOCATION: g_value_set_string (value, _bamf_dbus_item_tab_get_location (priv->proxy)); break; case PROP_DESKTOP_ID: g_value_set_string (value, _bamf_dbus_item_tab_get_desktop_id (priv->proxy)); break; case PROP_XID: g_value_set_uint64 (value, _bamf_dbus_item_tab_get_xid (priv->proxy)); break; case PROP_IS_FOREGROUND_TAB: g_value_set_boolean (value, _bamf_dbus_item_tab_get_is_foreground_tab (priv->proxy)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void bamf_tab_unset_proxy (BamfTab *self) { BamfTabPrivate *priv = bamf_tab_get_instance_private (self); if (!G_IS_DBUS_PROXY (priv->proxy)) return; g_signal_handlers_disconnect_by_data (priv->proxy, self); g_object_unref (priv->proxy); priv->proxy = NULL; } static void bamf_tab_dispose (GObject *object) { BamfTab *self; self = BAMF_TAB (object); bamf_tab_unset_proxy (self); if (G_OBJECT_CLASS (bamf_tab_parent_class)->dispose) G_OBJECT_CLASS (bamf_tab_parent_class)->dispose (object); } static void bamf_tab_class_init (BamfTabClass *klass) { GParamSpec *pspec; GObjectClass *obj_class = G_OBJECT_CLASS (klass); BamfViewClass *view_class = BAMF_VIEW_CLASS (klass); obj_class->dispose = bamf_tab_dispose; obj_class->get_property = bamf_tab_get_property; view_class->set_path = bamf_tab_set_path; pspec = g_param_spec_string("location", "Location", "The Current location of the remote Tab", NULL, G_PARAM_READABLE); g_object_class_install_property (obj_class, PROP_LOCATION, pspec); pspec = g_param_spec_string("desktop-id", "Desktop Name", "The Desktop ID associated with the application hosted in the remote Tab", NULL, G_PARAM_READABLE); g_object_class_install_property (obj_class, PROP_DESKTOP_ID, pspec); pspec = g_param_spec_uint64("xid", "xid", "XID for the toplevel window containing the remote Tab", 0, G_MAXUINT64, 0, G_PARAM_READABLE); g_object_class_install_property (obj_class, PROP_XID, pspec); pspec = g_param_spec_boolean("is-foreground-tab", "Foreground tab", "Whether the tab is the foreground tab in it's toplevel container", FALSE, G_PARAM_READABLE); g_object_class_install_property (obj_class, PROP_IS_FOREGROUND_TAB, pspec); } static void bamf_tab_init (BamfTab *self) { } BamfTab * bamf_tab_new (const gchar *path) { BamfTab *self; self = g_object_new (BAMF_TYPE_TAB, NULL); _bamf_view_set_path (BAMF_VIEW (self), path); return self; } /** * bamf_tab_raise: * @self: A #BamfTab. * * Selects the @self tab in the parent window. * * Returns: %TRUE if success, %FALSE otherwise. */ gboolean bamf_tab_raise (BamfTab *self) { GError *error = NULL; BamfTabPrivate *priv; g_return_val_if_fail (BAMF_IS_TAB (self), FALSE); if (!_bamf_view_remote_ready (BAMF_VIEW (self))) return FALSE; priv = bamf_tab_get_instance_private (self); if (!_bamf_dbus_item_tab_call_raise_sync (priv->proxy, CANCELLABLE (self), &error)) { g_warning ("Failed to invoke Raise method: %s", error ? error->message : ""); g_error_free (error); return FALSE; } return TRUE; } /** * bamf_tab_close: * @self: A #BamfTab. * * Closes the selected @self tab. * * Returns: %TRUE if success, %FALSE otherwise. */ gboolean bamf_tab_close (BamfTab *self) { BamfTabPrivate *priv; GError *error; g_return_val_if_fail (BAMF_IS_TAB (self), FALSE); if (!_bamf_view_remote_ready (BAMF_VIEW (self))) return FALSE; error = NULL; priv = bamf_tab_get_instance_private (self); if (!_bamf_dbus_item_tab_call_close_sync (priv->proxy, CANCELLABLE (self), &error)) { g_warning ("Failed to invoke Close method: %s", error->message); g_error_free (error); return FALSE; } return TRUE; } typedef struct _BamfTabPreviewRequestData { BamfTab *self; BamfTabPreviewReadyCallback callback; gpointer user_data; } BamfTabPreviewRequestData; static void on_preview_ready (GObject *source_object, GAsyncResult *res, gpointer user_data) { BamfTab *self; BamfTabPrivate *priv; BamfTabPreviewRequestData *data; gchar *preview_data = NULL; GError *error = NULL; data = user_data; self = data->self; priv = bamf_tab_get_instance_private (self); if (_bamf_dbus_item_tab_call_request_preview_finish (priv->proxy, &preview_data, res, &error)) { data->callback (self, preview_data, data->user_data); g_free (preview_data); } else { data->callback (self, NULL, data->user_data); g_warning ("Error requesting BamfTab preview: %s", error ? error->message : ""); g_error_free (error); } g_free (data); } /** * bamf_tab_request_preview: * @self: a #BamfTab * @callback: (closure) (scope async): a callback function to call when the result is ready * @user_data: (closure) (allow-none): data to be sent to the callback. */ void bamf_tab_request_preview (BamfTab *self, BamfTabPreviewReadyCallback callback, gpointer user_data) { BamfTabPreviewRequestData *data; BamfTabPrivate *priv; g_return_if_fail (BAMF_IS_TAB (self)); g_return_if_fail (callback != NULL); data = g_malloc (sizeof (BamfTabPreviewRequestData)); data->self = self; data->callback = callback; data->user_data = user_data; priv = bamf_tab_get_instance_private (self); _bamf_dbus_item_tab_call_request_preview (priv->proxy, NULL, on_preview_ready, data); } const gchar * bamf_tab_get_location (BamfTab *self) { BamfTabPrivate *priv; g_return_val_if_fail (BAMF_IS_TAB (self), NULL); if (BAMF_TAB_GET_CLASS (self)->get_location) return BAMF_TAB_GET_CLASS (self)->get_location (self); priv = bamf_tab_get_instance_private (self); return _bamf_dbus_item_tab_get_location (priv->proxy); } /** * bamf_tab_get_desktop_name: * @self: A #BamfTab. * * Returns the desktop file for the tab. * * Returns: (transfer none): The tab desktop id or %NULL if not set or available. Do not free the returned value, it belongs to @self. */ const gchar * bamf_tab_get_desktop_name (BamfTab *self) { BamfTabPrivate *priv; g_return_val_if_fail (BAMF_IS_TAB (self), NULL); if (BAMF_TAB_GET_CLASS (self)->get_desktop_name) return BAMF_TAB_GET_CLASS (self)->get_desktop_name (self); priv = bamf_tab_get_instance_private (self); return _bamf_dbus_item_tab_get_desktop_id (priv->proxy); } /** * bamf_tab_get_xid: * @self: A #BamfTab. * * The desktop file for the tab. * * Returns: The tab parent window XID id or 0 if not set or available. */ guint64 bamf_tab_get_xid (BamfTab *self) { BamfTabPrivate *priv; g_return_val_if_fail (BAMF_IS_TAB (self), 0); if (BAMF_TAB_GET_CLASS (self)->get_xid) return BAMF_TAB_GET_CLASS (self)->get_xid (self); priv = bamf_tab_get_instance_private (self); return _bamf_dbus_item_tab_get_xid (priv->proxy); } /** * bamf_tab_get_is_foreground_tab: * @self: A #BamfTab. * * Returns: %TRUE if the tab is the active one on parent window XID, %FALSE otherwise. */ gboolean bamf_tab_get_is_foreground_tab (BamfTab *self) { BamfTabPrivate *priv; g_return_val_if_fail (BAMF_IS_TAB (self), FALSE); if (BAMF_TAB_GET_CLASS (self)->get_is_foreground_tab) return BAMF_TAB_GET_CLASS (self)->get_is_foreground_tab (self); priv = bamf_tab_get_instance_private (self); return _bamf_dbus_item_tab_get_is_foreground_tab (priv->proxy); } ./lib/libbamf/bamf-window.h0000644000004100000410000000745114203512426015776 0ustar www-datawww-data/* * Copyright 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef _BAMF_WINDOW_H_ #define _BAMF_WINDOW_H_ #include #include #include G_BEGIN_DECLS #define BAMF_TYPE_WINDOW (bamf_window_get_type ()) #define BAMF_WINDOW_SIGNAL_MONITOR_CHANGED "monitor-changed" #define BAMF_WINDOW_SIGNAL_MAXIMIZED_CHANGED "maximized-changed" G_DECLARE_DERIVABLE_TYPE (BamfWindow, bamf_window, BAMF, WINDOW, BamfView); typedef enum { BAMF_WINDOW_NORMAL, /* document/app window */ BAMF_WINDOW_DESKTOP, /* desktop background */ BAMF_WINDOW_DOCK, /* panel */ BAMF_WINDOW_DIALOG, /* dialog */ BAMF_WINDOW_TOOLBAR, /* tearoff toolbar */ BAMF_WINDOW_MENU, /* tearoff menu */ BAMF_WINDOW_UTILITY, /* palette/toolbox window */ BAMF_WINDOW_SPLASHSCREEN, /* splash screen */ BAMF_WINDOW_UNKNOWN } BamfWindowType; typedef enum { BAMF_WINDOW_FLOATING, /* Floating window */ BAMF_WINDOW_HORIZONTAL_MAXIMIZED, /* Horizontally maximized window */ BAMF_WINDOW_VERTICAL_MAXIMIZED, /* Vertically maximized window */ BAMF_WINDOW_MAXIMIZED /* Maximized window */ } BamfWindowMaximizationType; struct _BamfWindowClass { BamfViewClass parent_class; BamfWindow * (*get_transient) (BamfWindow *self); BamfWindowType (*get_window_type) (BamfWindow *self); guint32 (*get_xid) (BamfWindow *self); guint32 (*get_pid) (BamfWindow *self); gint (*get_monitor) (BamfWindow *self); gchar * (*get_utf8_prop) (BamfWindow *self, const char* prop); BamfWindowMaximizationType (*maximized) (BamfWindow *self); time_t (*last_active) (BamfWindow *self); /*< signals >*/ void (*monitor_changed) (BamfWindow *window, gint old_value, gint new_value); void (*maximized_changed) (BamfWindow *window, gint old_value, gint new_value); /*< private >*/ void (*_window_padding1) (void); void (*_window_padding2) (void); void (*_window_padding3) (void); void (*_window_padding4) (void); }; BamfWindow * bamf_window_get_transient (BamfWindow *self); BamfWindowType bamf_window_get_window_type (BamfWindow *self); guint32 bamf_window_get_xid (BamfWindow *self); guint32 bamf_window_get_pid (BamfWindow *self); gint bamf_window_get_monitor (BamfWindow *self); gchar * bamf_window_get_utf8_prop (BamfWindow *self, const char* prop); BamfWindowMaximizationType bamf_window_maximized (BamfWindow *self); time_t bamf_window_last_active (BamfWindow *self); G_END_DECLS #endif ./lib/libbamf/bamf-factory.h0000644000004100000410000000701414203512426016131 0ustar www-datawww-data/* * Copyright 2010 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef _BAMF_FACTORY_H_ #define _BAMF_FACTORY_H_ #include #include #include #include G_BEGIN_DECLS #define BAMF_TYPE_FACTORY (bamf_factory_get_type ()) #define BAMF_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\ BAMF_TYPE_FACTORY, BamfFactory)) #define BAMF_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\ BAMF_TYPE_FACTORY, BamfFactoryClass)) #define BAMF_IS_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ BAMF_TYPE_FACTORY)) #define BAMF_IS_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ BAMF_TYPE_FACTORY)) #define BAMF_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ BAMF_TYPE_FACTORY, BamfFactoryClass)) typedef struct _BamfFactory BamfFactory; typedef struct _BamfFactoryClass BamfFactoryClass; typedef struct _BamfFactoryPrivate BamfFactoryPrivate; typedef enum { BAMF_FACTORY_VIEW, BAMF_FACTORY_WINDOW, BAMF_FACTORY_APPLICATION, BAMF_FACTORY_TAB, BAMF_FACTORY_NONE } BamfFactoryViewType; struct _BamfFactory { GObject parent; BamfFactoryPrivate *priv; }; struct _BamfFactoryClass { GObjectClass parent_class; }; GType bamf_factory_get_type (void) G_GNUC_CONST; BamfView * _bamf_factory_view_for_path (BamfFactory * factory, const char * path); BamfView * _bamf_factory_view_for_path_type (BamfFactory * factory, const char * path, BamfFactoryViewType type); BamfView * _bamf_factory_view_for_path_type_str (BamfFactory * factory, const char * path, const char * type); BamfWindow * _bamf_factory_window_for_xid (BamfFactory * factory, guint32 xid); BamfApplication * _bamf_factory_app_for_file (BamfFactory * factory, const char * path, gboolean create); BamfApplication * _bamf_factory_app_for_xid (BamfFactory * factory, guint32 xid); BamfFactory * _bamf_factory_get_default (void); G_END_DECLS #endif ./lib/libbamf/bamf-control.h0000644000004100000410000000615114203512426016143 0ustar www-datawww-data/* * Copyright 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef _BAMF_CONTROL_H_ #define _BAMF_CONTROL_H_ #include #include "bamf-application.h" G_BEGIN_DECLS #define BAMF_TYPE_CONTROL (bamf_control_get_type ()) #define BAMF_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\ BAMF_TYPE_CONTROL, BamfControl)) #define BAMF_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\ BAMF_TYPE_CONTROL, BamfControlClass)) #define BAMF_IS_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ BAMF_TYPE_CONTROL)) #define BAMF_IS_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ BAMF_TYPE_CONTROL)) #define BAMF_CONTROL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ BAMF_TYPE_CONTROL, BamfControlClass)) typedef struct _BamfControl BamfControl; typedef struct _BamfControlClass BamfControlClass; typedef struct _BamfControlPrivate BamfControlPrivate; struct _BamfControl { GObject parent; BamfControlPrivate *priv; }; struct _BamfControlClass { GObjectClass parent_class; /*< private >*/ void (*_control_padding1) (void); void (*_control_padding2) (void); void (*_control_padding3) (void); void (*_control_padding4) (void); void (*_control_padding5) (void); void (*_control_padding6) (void); }; GType bamf_control_get_type (void) G_GNUC_CONST; BamfControl * bamf_control_get_default (void); void bamf_control_insert_desktop_file (BamfControl *control, const gchar *desktop_file); void bamf_control_create_local_desktop_file (BamfControl *control, BamfApplication *application); void bamf_control_register_application_for_pid (BamfControl *control, const gchar *desktop_file, gint32 pid); void bamf_control_set_approver_behavior (BamfControl *control, gint32 behavior); G_END_DECLS #endif ./lib/libbamf/bamf-application.c0000644000004100000410000005452714203512426016773 0ustar www-datawww-data/* * Copyright 2010-2012 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ /** * SECTION:bamf-application * @short_description: The base class for all applications * * #BamfApplication is the base class that all applications need to derive from. */ #if HAVE_CONFIG_H #include #endif #include #include "bamf-application.h" #include "bamf-window.h" #include "bamf-factory.h" #include "bamf-application-private.h" #include "bamf-view-private.h" #include #include enum { DESKTOP_FILE_UPDATED, WINDOW_ADDED, WINDOW_REMOVED, LAST_SIGNAL, }; static guint application_signals[LAST_SIGNAL] = { 0 }; typedef struct _BamfApplicationPrivate { BamfDBusItemApplication *proxy; gchar *application_type; gchar *desktop_file; GList *cached_xids; gchar **cached_mimes; int show_stubs; } BamfApplicationPrivate; G_DEFINE_TYPE_WITH_PRIVATE (BamfApplication, bamf_application, BAMF_TYPE_VIEW); /** * bamf_application_get_supported_mime_types: * @application: a #BamfApplication * * Returns: (transfer full) (array zero-terminated=1): A string array containing the supported mime-types. */ gchar ** bamf_application_get_supported_mime_types (BamfApplication *application) { BamfApplicationPrivate *priv; GError *error = NULL; g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL); priv = bamf_application_get_instance_private (application); if (priv->cached_mimes) return g_strdupv (priv->cached_mimes); if (!_bamf_view_remote_ready (BAMF_VIEW (application))) return NULL; if (!_bamf_dbus_item_application_call_supported_mime_types_sync (priv->proxy, &priv->cached_mimes, CANCELLABLE (application), &error)) { priv->cached_mimes = NULL; g_warning ("Failed to fetch mimes: %s", error ? error->message : ""); g_error_free (error); } return g_strdupv (priv->cached_mimes); } /** * bamf_application_get_desktop_file: * @application: a #BamfApplication * * Used to fetch the path to the .desktop file associated with the passed application. If * none exists, the result is NULL. * * Returns: A string representing the path to the desktop file. */ const gchar * bamf_application_get_desktop_file (BamfApplication *application) { BamfApplicationPrivate *priv; gchar *file; GError *error = NULL; g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE); priv = bamf_application_get_instance_private (application); if (priv->desktop_file) return priv->desktop_file; if (!_bamf_view_remote_ready (BAMF_VIEW (application))) return NULL; if (!_bamf_dbus_item_application_call_desktop_file_sync (priv->proxy, &file, CANCELLABLE (application), &error)) { g_warning ("Failed to fetch path: %s", error ? error->message : ""); g_error_free (error); return NULL; } if (file && file[0] == '\0') { g_free (file); file = NULL; } priv->desktop_file = file; return file; } /** * bamf_application_get_application_menu: * @application: a #BamfApplication * @name: (out): the bus name * @object_path: (out): the object path * * Used to fetch the bus name and the object path of the remote application menu. * * Deprecated: 0.5.0 * Returns: %TRUE if found, %FALSE otherwise. */ gboolean bamf_application_get_application_menu (BamfApplication *application, gchar **name, gchar **object_path) { BamfApplicationPrivate *priv; GError *error = NULL; g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE); g_return_val_if_fail (name != NULL && object_path != NULL, FALSE); priv = bamf_application_get_instance_private (application); if (!_bamf_view_remote_ready (BAMF_VIEW (application))) return FALSE; G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (!_bamf_dbus_item_application_call_application_menu_sync (priv->proxy, name, object_path, CANCELLABLE (application), &error)) G_GNUC_END_IGNORE_DEPRECATIONS { *name = NULL; *object_path = NULL; g_warning ("Failed to fetch application menu path: %s", error ? error->message : ""); g_error_free (error); return FALSE; } return TRUE; } /** * bamf_application_get_applicaton_type: * @application: a #BamfApplication * * Used to determine what type of application a .desktop file represents. Current values are: * "system" : A normal application, like firefox or evolution * "web" : A web application, like facebook or twitter * * Returns: A string */ const gchar * bamf_application_get_application_type (BamfApplication *application) { BamfApplicationPrivate *priv; gchar *type; GError *error = NULL; g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE); priv = bamf_application_get_instance_private (application); if (priv->application_type) return priv->application_type; if (!_bamf_view_remote_ready (BAMF_VIEW (application))) return NULL; if (!_bamf_dbus_item_application_call_application_type_sync (priv->proxy, &type, CANCELLABLE (application), &error)) { g_warning ("Failed to fetch path: %s", error ? error->message : ""); g_error_free (error); return NULL; } priv->application_type = type; return type; } /** * bamf_application_get_xids: * @application: a #BamfApplication * * Used to fetch all #BamfWindow's xids associated with the passed #BamfApplication. * * Returns: (element-type guint32) (transfer full): An array of xids. */ GArray * bamf_application_get_xids (BamfApplication *application) { BamfApplicationPrivate *priv; GVariantIter *iter; GVariant *xids_variant; GArray *xids; GList *children, *l; guint32 xid; GError *error = NULL; g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE); priv = bamf_application_get_instance_private (application); if (!_bamf_view_remote_ready (BAMF_VIEW (application))) return NULL; children = bamf_view_peek_children (BAMF_VIEW (application)); if (children) { xids = g_array_new (FALSE, TRUE, sizeof (guint32)); for (l = children; l; l = l->next) { if (!BAMF_IS_WINDOW (l->data)) continue; xid = bamf_window_get_xid (BAMF_WINDOW (l->data)); g_array_append_val (xids, xid); } return xids; } if (!_bamf_dbus_item_application_call_xids_sync (priv->proxy, &xids_variant, CANCELLABLE (application), &error)) { g_warning ("Failed to fetch xids: %s", error ? error->message : ""); g_error_free (error); return NULL; } g_return_val_if_fail (xids_variant, NULL); g_return_val_if_fail (g_variant_type_equal (g_variant_get_type (xids_variant), G_VARIANT_TYPE ("au")), NULL); xids = g_array_new (FALSE, TRUE, sizeof (guint32)); g_variant_get (xids_variant, "au", &iter); while (g_variant_iter_loop (iter, "u", &xid)) { g_array_append_val (xids, xid); } g_variant_iter_free (iter); g_variant_unref (xids_variant); return xids; } /** * bamf_application_get_windows: * @application: a #BamfApplication * * Used to fetch all #BamfWindow's associated with the passed #BamfApplication. * * Returns: (element-type Bamf.Window) (transfer container): A list of #BamfWindow's. */ GList * bamf_application_get_windows (BamfApplication *application) { GList *children, *l, *next; BamfView *view; g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL); children = bamf_view_get_children (BAMF_VIEW (application)); l = children; while (l != NULL) { view = l->data; next = l->next; if (!BAMF_IS_WINDOW (view)) { children = g_list_delete_link (children, l); } l = next; } return children; } /** * bamf_application_get_window_for_xid: * @application: a #BamfApplication * @xid: an X11 Window ID * * Used to fetch the application contains a Window with given @xid. * * Since: 0.5.2 * Returns: (transfer none): a #BamfWindow for the passed @xid or %NULL if not found. */ BamfWindow * bamf_application_get_window_for_xid (BamfApplication *application, guint32 xid) { GList *l; BamfWindow *window; g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE); for (l = bamf_view_peek_children (BAMF_VIEW (application)); l; l = l->next) { if (BAMF_IS_WINDOW (l->data)) { window = BAMF_WINDOW (l->data); if (bamf_window_get_xid (window) == xid) return window; } } return NULL; } /** * bamf_application_get_show_menu_stubs: * @application: a #BamfApplication * * Used to discover whether the application wants menu stubs shown. * * Returns: Whether the stubs should be shown. */ gboolean bamf_application_get_show_menu_stubs (BamfApplication * application) { BamfApplicationPrivate *priv; GError *error = NULL; gboolean result; g_return_val_if_fail (BAMF_IS_APPLICATION (application), TRUE); priv = bamf_application_get_instance_private (application); if (!_bamf_view_remote_ready (BAMF_VIEW (application))) return TRUE; if (priv->show_stubs == -1) { if (!_bamf_dbus_item_application_call_show_stubs_sync (priv->proxy, &result, CANCELLABLE (application), &error)) { g_warning ("Failed to fetch show_stubs: %s", error ? error->message : ""); g_error_free (error); return TRUE; } if (result) priv->show_stubs = 1; else priv->show_stubs = 0; } return priv->show_stubs; } static BamfClickBehavior bamf_application_get_click_suggestion (BamfView *view) { if (!bamf_view_is_running (view)) return BAMF_CLICK_BEHAVIOR_OPEN; return 0; } /** * bamf_application_get_focusable_child: * @application: a #BamfApplication * * Returns: (transfer none): The focusable child for this application. */ BamfView * bamf_application_get_focusable_child (BamfApplication *application) { BamfApplicationPrivate *priv; BamfView *ret; gchar *path; GError *error = NULL; g_return_val_if_fail (BAMF_IS_APPLICATION (application), FALSE); priv = bamf_application_get_instance_private (application); if (!_bamf_view_remote_ready (BAMF_VIEW (application))) return NULL; if (!_bamf_dbus_item_application_call_focusable_child_sync (priv->proxy, &path, CANCELLABLE (application), &error)) { g_warning ("Failed to fetch focusable child: %s", error ? error->message : ""); g_error_free (error); return NULL; } ret = _bamf_factory_view_for_path (_bamf_factory_get_default (), path); g_free (path); return ret; } static void bamf_application_on_desktop_file_updated (BamfDBusItemApplication *proxy, const char *desktop_file, BamfApplication *self) { BamfApplicationPrivate *priv = bamf_application_get_instance_private (self); g_free (priv->desktop_file); priv->desktop_file = g_strdup (desktop_file); g_signal_emit (self, application_signals[DESKTOP_FILE_UPDATED], 0, desktop_file); } static void bamf_application_on_child_added (BamfApplication *self, BamfView *view) { BamfApplicationPrivate *priv = bamf_application_get_instance_private (self); if (BAMF_IS_WINDOW (view)) { guint32 xid = bamf_window_get_xid (BAMF_WINDOW (view)); if (!g_list_find (priv->cached_xids, GUINT_TO_POINTER (xid))) { priv->cached_xids = g_list_prepend (priv->cached_xids, GUINT_TO_POINTER (xid)); } g_signal_emit (G_OBJECT (self), application_signals[WINDOW_ADDED], 0, view); } } static void bamf_application_on_child_removed (BamfApplication *self, BamfView *view) { BamfApplicationPrivate *priv = bamf_application_get_instance_private (self); if (BAMF_IS_WINDOW (view)) { guint32 xid = bamf_window_get_xid (BAMF_WINDOW (view)); priv->cached_xids = g_list_remove (priv->cached_xids, GUINT_TO_POINTER (xid)); g_signal_emit (G_OBJECT (self), application_signals[WINDOW_REMOVED], 0, view); } } GList * _bamf_application_get_cached_xids (BamfApplication *self) { BamfApplicationPrivate *priv; g_return_val_if_fail (BAMF_IS_APPLICATION (self), NULL); priv = bamf_application_get_instance_private (self); return priv->cached_xids; } static void bamf_application_on_supported_mime_types_changed (BamfDBusItemApplication *proxy, const gchar *const *mimes, BamfApplication *self) { BamfApplicationPrivate *priv = bamf_application_get_instance_private (self); if (priv->cached_mimes) g_strfreev (priv->cached_mimes); priv->cached_mimes = g_strdupv ((gchar**)mimes); } static void bamf_application_unset_proxy (BamfApplication* self) { BamfApplicationPrivate *priv; g_return_if_fail (BAMF_IS_APPLICATION (self)); priv = bamf_application_get_instance_private (self); if (G_IS_DBUS_PROXY (priv->proxy)) { g_signal_handlers_disconnect_by_data (priv->proxy, self); g_object_unref (priv->proxy); priv->proxy = NULL; } } static void bamf_application_dispose (GObject *object) { BamfApplication *self; BamfApplicationPrivate *priv; self = BAMF_APPLICATION (object); priv = bamf_application_get_instance_private (self); if (priv->application_type) { g_free (priv->application_type); priv->application_type = NULL; } if (priv->desktop_file) { g_free (priv->desktop_file); priv->desktop_file = NULL; } if (priv->cached_xids) { g_list_free (priv->cached_xids); priv->cached_xids = NULL; } if (priv->cached_mimes) { g_strfreev (priv->cached_mimes); priv->cached_mimes = NULL; } bamf_application_unset_proxy (self); if (G_OBJECT_CLASS (bamf_application_parent_class)->dispose) G_OBJECT_CLASS (bamf_application_parent_class)->dispose (object); } static void bamf_application_set_path (BamfView *view, const char *path) { BamfApplication *self; BamfApplicationPrivate *priv; GError *error = NULL; self = BAMF_APPLICATION (view); priv = bamf_application_get_instance_private (self); bamf_application_unset_proxy (self); priv->proxy = _bamf_dbus_item_application_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, BAMF_DBUS_SERVICE_NAME, path, CANCELLABLE (view), &error); if (!G_IS_DBUS_PROXY (priv->proxy)) { g_critical ("Unable to get %s application: %s", BAMF_DBUS_SERVICE_NAME, error ? error->message : ""); g_clear_error (&error); return; } g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (priv->proxy), BAMF_DBUS_DEFAULT_TIMEOUT); g_signal_connect (priv->proxy, "desktop-file-updated", G_CALLBACK (bamf_application_on_desktop_file_updated), view); g_signal_connect (priv->proxy, "supported-mime-types-changed", G_CALLBACK (bamf_application_on_supported_mime_types_changed), view); GList *children, *l; children = bamf_view_peek_children (view); if (priv->cached_xids) { g_list_free (priv->cached_xids); priv->cached_xids = NULL; } for (l = children; l; l = l->next) { if (!BAMF_IS_WINDOW (l->data)) continue; guint32 xid = bamf_window_get_xid (BAMF_WINDOW (l->data)); priv->cached_xids = g_list_prepend (priv->cached_xids, GUINT_TO_POINTER (xid)); } } static void bamf_application_set_sticky (BamfView *view, gboolean sticky) { BamfApplication *self = BAMF_APPLICATION (view); BamfApplicationPrivate *priv = bamf_application_get_instance_private (self); if (sticky) { bamf_application_get_desktop_file (self); bamf_application_get_application_type (self); /* When setting the application sticky, we need to cache the relevant values */ if (!priv->cached_mimes) { gchar **tmp_mimes = bamf_application_get_supported_mime_types (self); g_strfreev (tmp_mimes); } gchar *tmp; tmp = bamf_view_get_icon (view); g_free (tmp); tmp = bamf_view_get_name (view); g_free (tmp); } } static void bamf_application_load_data_from_file (BamfApplication *self, GKeyFile * keyfile) { BamfApplicationPrivate *priv = bamf_application_get_instance_private (self); GDesktopAppInfo *desktop_info; GIcon *gicon; char *fullname; char *name; char *icon; g_return_if_fail (keyfile); desktop_info = g_desktop_app_info_new_from_keyfile (keyfile); g_return_if_fail (G_IS_DESKTOP_APP_INFO (desktop_info)); name = g_strdup (g_app_info_get_name (G_APP_INFO (desktop_info))); /* Grab the better name if its available */ fullname = g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_FULLNAME, NULL, NULL); if (fullname && fullname[0] == '\0') { g_free (fullname); fullname = NULL; } if (fullname) { g_free (name); name = fullname; } _bamf_view_set_cached_name (BAMF_VIEW (self), name); gicon = g_app_info_get_icon (G_APP_INFO (desktop_info)); icon = gicon ? g_icon_to_string (gicon) : NULL; if (!icon) icon = g_strdup (BAMF_APPLICATION_DEFAULT_ICON); _bamf_view_set_cached_icon (BAMF_VIEW (self), icon); priv->cached_mimes = g_key_file_get_string_list (keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_MIME_TYPE, NULL, NULL); priv->application_type = g_strdup ("system"); g_free (icon); g_free (name); g_key_file_free (keyfile); g_object_unref (desktop_info); } static void bamf_application_class_init (BamfApplicationClass *klass) { GObjectClass *obj_class = G_OBJECT_CLASS (klass); BamfViewClass *view_class = BAMF_VIEW_CLASS (klass); obj_class->dispose = bamf_application_dispose; view_class->set_path = bamf_application_set_path; view_class->set_sticky = bamf_application_set_sticky; view_class->click_behavior = bamf_application_get_click_suggestion; application_signals [DESKTOP_FILE_UPDATED] = g_signal_new (BAMF_APPLICATION_SIGNAL_DESKTOP_FILE_UPDATED, G_OBJECT_CLASS_TYPE (klass), 0, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING); application_signals [WINDOW_ADDED] = g_signal_new (BAMF_APPLICATION_SIGNAL_WINDOW_ADDED, G_OBJECT_CLASS_TYPE (klass), 0, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, BAMF_TYPE_WINDOW); application_signals [WINDOW_REMOVED] = g_signal_new (BAMF_APPLICATION_SIGNAL_WINDOW_REMOVED, G_OBJECT_CLASS_TYPE (klass), 0, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, BAMF_TYPE_WINDOW); } static void bamf_application_init (BamfApplication *self) { BamfApplicationPrivate *priv; priv = bamf_application_get_instance_private (self); priv->show_stubs = -1; g_signal_connect (self, "child-added", G_CALLBACK (bamf_application_on_child_added), NULL); g_signal_connect (self, "child-removed", G_CALLBACK (bamf_application_on_child_removed), NULL); } BamfApplication * bamf_application_new (const char * path) { BamfApplication *self; self = g_object_new (BAMF_TYPE_APPLICATION, NULL); _bamf_view_set_path (BAMF_VIEW (self), path); return self; } BamfApplication * bamf_application_new_favorite (const char * favorite_path) { BamfApplication *self; BamfApplicationPrivate *priv; GKeyFile *desktop_keyfile; gchar *type; gboolean supported = FALSE; g_return_val_if_fail (favorite_path, NULL); // check that we support this kind of desktop file desktop_keyfile = g_key_file_new (); if (g_key_file_load_from_file (desktop_keyfile, favorite_path, G_KEY_FILE_NONE, NULL)) { type = g_key_file_get_string (desktop_keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TYPE, NULL); if (g_strcmp0 (type, G_KEY_FILE_DESKTOP_TYPE_APPLICATION) == 0) supported = TRUE; g_free (type); } if (!supported) { g_key_file_free (desktop_keyfile); return NULL; } self = g_object_new (BAMF_TYPE_APPLICATION, NULL); priv = bamf_application_get_instance_private (self); priv->desktop_file = g_strdup (favorite_path); bamf_application_load_data_from_file (self, desktop_keyfile); return self; } ./lib/libbamf/bamf-matcher.c0000644000004100000410000006355614203512426016115 0ustar www-datawww-data/* * Copyright 2010-2012 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ /** * SECTION:bamf-matcher * @short_description: The base class for all matchers * * #BamfMatcher is the base class that all matchers need to derive from. */ #if HAVE_CONFIG_H #include #endif #include #include "bamf-matcher.h" #include "bamf-tab.h" #include "bamf-view.h" #include "bamf-view-private.h" #include "bamf-factory.h" enum { VIEW_OPENED, VIEW_CLOSED, ACTIVE_APPLICATION_CHANGED, ACTIVE_WINDOW_CHANGED, STACKING_ORDER_CHANGED, LAST_SIGNAL, }; static guint matcher_signals[LAST_SIGNAL] = { 0 }; struct _BamfMatcherPrivate { BamfDBusMatcher *proxy; GCancellable *cancellable; BamfWindow *active_window; BamfApplication *active_application; }; G_DEFINE_TYPE_WITH_PRIVATE (BamfMatcher, bamf_matcher, G_TYPE_OBJECT); static BamfMatcher * default_matcher = NULL; static void bamf_matcher_dispose (GObject *object); static void bamf_matcher_finalize (GObject *object) { default_matcher = NULL; g_object_unref (_bamf_factory_get_default ()); G_OBJECT_CLASS (bamf_matcher_parent_class)->finalize (object); } static void bamf_matcher_class_init (BamfMatcherClass *klass) { GObjectClass *obj_class = G_OBJECT_CLASS (klass); obj_class->dispose = bamf_matcher_dispose; obj_class->finalize = bamf_matcher_finalize; matcher_signals [VIEW_OPENED] = g_signal_new (BAMF_MATCHER_SIGNAL_VIEW_OPENED, G_OBJECT_CLASS_TYPE (klass), 0, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, BAMF_TYPE_VIEW); matcher_signals [VIEW_CLOSED] = g_signal_new (BAMF_MATCHER_SIGNAL_VIEW_CLOSED, G_OBJECT_CLASS_TYPE (klass), 0, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, BAMF_TYPE_VIEW); matcher_signals [ACTIVE_APPLICATION_CHANGED] = g_signal_new (BAMF_MATCHER_SIGNAL_ACTIVE_APPLICATION_CHANGED, G_OBJECT_CLASS_TYPE (klass), 0, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, BAMF_TYPE_APPLICATION, BAMF_TYPE_APPLICATION); matcher_signals [ACTIVE_WINDOW_CHANGED] = g_signal_new (BAMF_MATCHER_SIGNAL_ACTIVE_WINDOW_CHANGED, G_OBJECT_CLASS_TYPE (klass), 0, 0, NULL, NULL, NULL, G_TYPE_NONE, 2, BAMF_TYPE_WINDOW, BAMF_TYPE_WINDOW); matcher_signals [STACKING_ORDER_CHANGED] = g_signal_new (BAMF_MATCHER_SIGNAL_STACKING_ORDER_CHANGED, G_OBJECT_CLASS_TYPE (klass), 0, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); } static gboolean track_ptr (GType wanted_type, BamfView *active, gpointer *cache_pointer) { if (G_TYPE_CHECK_INSTANCE_TYPE (active, wanted_type)) { if (*cache_pointer == active) return FALSE; *cache_pointer = active; g_object_add_weak_pointer (G_OBJECT (active), cache_pointer); return TRUE; } else if (G_TYPE_CHECK_INSTANCE_TYPE (*cache_pointer, wanted_type)) { g_object_remove_weak_pointer (G_OBJECT (*cache_pointer), cache_pointer); *cache_pointer = NULL; return TRUE; } return FALSE; } static void bamf_matcher_on_name_owner_changed (BamfDBusMatcher *proxy, GParamSpec *param, BamfMatcher *matcher) { /* This is called when the bamfdaemon is killed / started */ gchar *name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (proxy)); if (!name_owner) { track_ptr (BAMF_TYPE_APPLICATION, NULL, (gpointer *) &matcher->priv->active_application); track_ptr (BAMF_TYPE_WINDOW, NULL, (gpointer *) &matcher->priv->active_window); } g_free (name_owner); } static void bamf_matcher_on_view_opened (BamfDBusMatcher *proxy, const char *path, const char *type, BamfMatcher *matcher) { BamfView *view; BamfFactory *factory = _bamf_factory_get_default (); view = _bamf_factory_view_for_path_type_str (factory, path, type); if (!BAMF_IS_VIEW (view)) return; /* We manually set the view as not closed, to avoid issues like bug #925421 */ _bamf_view_set_closed (view, FALSE); g_signal_emit (matcher, matcher_signals[VIEW_OPENED], 0, view); } static void bamf_matcher_on_view_closed (BamfDBusMatcher *proxy, const char *path, const char *type, BamfMatcher *matcher) { BamfView *view; BamfFactory *factory = _bamf_factory_get_default (); view = _bamf_factory_view_for_path_type_str (factory, path, type); if (!BAMF_IS_VIEW (view)) return; /* We manually set the view as closed, to avoid issues like bug #925421 */ _bamf_view_set_closed (view, TRUE); g_signal_emit (matcher, matcher_signals[VIEW_CLOSED], 0, view); } static void bamf_matcher_on_active_application_changed (BamfDBusMatcher *proxy, const char *old_path, const char *new_path, BamfMatcher *matcher) { BamfView *old_view; BamfView *new_view; BamfFactory *factory; factory = _bamf_factory_get_default (); old_view = _bamf_factory_view_for_path_type (factory, old_path, BAMF_FACTORY_APPLICATION); new_view = _bamf_factory_view_for_path_type (factory, new_path, BAMF_FACTORY_APPLICATION); if (track_ptr (BAMF_TYPE_APPLICATION, new_view, (gpointer *) &matcher->priv->active_application)) { g_signal_emit (matcher, matcher_signals[ACTIVE_APPLICATION_CHANGED], 0, old_view, new_view); } } static void bamf_matcher_on_active_window_changed (BamfDBusMatcher *proxy, const char *old_path, const char *new_path, BamfMatcher *matcher) { BamfView *old_view; BamfView *new_view; BamfApplication *old_app; BamfApplication *new_app; BamfFactory *factory; BamfMatcherPrivate *priv; priv = matcher->priv; old_app = priv->active_application; new_app = old_app; factory = _bamf_factory_get_default (); old_view = _bamf_factory_view_for_path_type (factory, old_path, BAMF_FACTORY_WINDOW); new_view = _bamf_factory_view_for_path_type (factory, new_path, BAMF_FACTORY_WINDOW); track_ptr (BAMF_TYPE_WINDOW, new_view, (gpointer *) &priv->active_window); if (BAMF_IS_WINDOW (new_view)) new_app = _bamf_factory_app_for_xid (factory, bamf_window_get_xid (BAMF_WINDOW (new_view))); track_ptr (BAMF_TYPE_APPLICATION, (BamfView *) new_app, (gpointer *) &priv->active_application); g_signal_emit (matcher, matcher_signals[ACTIVE_WINDOW_CHANGED], 0, old_view, new_view); if (new_app != old_app) { g_signal_emit (matcher, matcher_signals[ACTIVE_APPLICATION_CHANGED], 0, old_app, new_app); } } static void bamf_matcher_on_stacking_order_changed (BamfDBusMatcher *proxy, BamfMatcher *matcher) { g_signal_emit (matcher, matcher_signals[STACKING_ORDER_CHANGED], 0); } static void bamf_matcher_init (BamfMatcher *self) { BamfMatcherPrivate *priv; GError *error = NULL; priv = self->priv = bamf_matcher_get_instance_private (self); priv->cancellable = g_cancellable_new (); priv->proxy = _bamf_dbus_matcher_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, BAMF_DBUS_SERVICE_NAME, BAMF_DBUS_MATCHER_PATH, priv->cancellable, &error); if (error) { g_warning ("Unable to get %s matcher: %s", BAMF_DBUS_SERVICE_NAME, error ? error->message : ""); g_error_free (error); } g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (priv->proxy), BAMF_DBUS_DEFAULT_TIMEOUT); g_signal_connect (priv->proxy, "notify::g-name-owner", G_CALLBACK (bamf_matcher_on_name_owner_changed), self); g_signal_connect (priv->proxy, "view-opened", G_CALLBACK (bamf_matcher_on_view_opened), self); g_signal_connect (priv->proxy, "view-closed", G_CALLBACK (bamf_matcher_on_view_closed), self); g_signal_connect (priv->proxy, "active-application-changed", G_CALLBACK (bamf_matcher_on_active_application_changed), self); g_signal_connect (priv->proxy, "active-window-changed", G_CALLBACK (bamf_matcher_on_active_window_changed), self); g_signal_connect (priv->proxy, "stacking-order-changed", G_CALLBACK (bamf_matcher_on_stacking_order_changed), self); } static void bamf_matcher_dispose (GObject *object) { BamfMatcher *self = BAMF_MATCHER (object); if (G_IS_DBUS_PROXY (self->priv->proxy)) { g_signal_handlers_disconnect_by_data (self->priv->proxy, self); g_object_unref (self->priv->proxy); self->priv->proxy = NULL; } if (G_IS_CANCELLABLE (self->priv->cancellable)) { g_cancellable_cancel (self->priv->cancellable); g_object_unref (self->priv->cancellable); } G_OBJECT_CLASS (bamf_matcher_parent_class)->dispose (object); } /* * Public Methods */ /** * bamf_matcher_get_default: * * Returns the default matcher. This matcher is owned by bamf and shared between other callers. * * Returns: (transfer full): A new #BamfMatcher */ BamfMatcher * bamf_matcher_get_default (void) { if (BAMF_IS_MATCHER (default_matcher)) return g_object_ref (default_matcher); return (default_matcher = g_object_new (BAMF_TYPE_MATCHER, NULL)); } /** * bamf_matcher_get_active_application: * @matcher: a #BamfMatcher * * Used to fetch the active #BamfApplication. * * Returns: (transfer none): The active #BamfApplication. */ BamfApplication * bamf_matcher_get_active_application (BamfMatcher *matcher) { BamfMatcherPrivate *priv; BamfView *view; char *app = NULL; GError *error = NULL; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); priv = matcher->priv; if (BAMF_IS_APPLICATION (priv->active_application)) { if (!bamf_view_is_closed (BAMF_VIEW (priv->active_application))) return priv->active_application; } if (!_bamf_dbus_matcher_call_active_application_sync (priv->proxy, &app, priv->cancellable, &error)) { g_warning ("Failed to get active application: %s", error ? error->message : ""); g_error_free (error); track_ptr (BAMF_TYPE_APPLICATION, NULL, (gpointer *) &priv->active_application); return NULL; } BamfFactory *factory = _bamf_factory_get_default (); view = _bamf_factory_view_for_path_type (factory, app, BAMF_FACTORY_APPLICATION); g_free (app); if (!BAMF_IS_APPLICATION (view)) view = NULL; track_ptr (BAMF_TYPE_APPLICATION, view, (gpointer *) &priv->active_application); return priv->active_application; } /** * bamf_matcher_get_active_window: * @matcher: a #BamfMatcher * * Used to fetch the active #BamfWindow. * * Returns: (transfer none): The active #BamfWindow. */ BamfWindow * bamf_matcher_get_active_window (BamfMatcher *matcher) { BamfMatcherPrivate *priv; BamfView *view; char *win = NULL; GError *error = NULL; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); priv = matcher->priv; if (BAMF_IS_APPLICATION (priv->active_window)) { if (!bamf_view_is_closed (BAMF_VIEW (priv->active_window))) return priv->active_window; } if (!_bamf_dbus_matcher_call_active_window_sync (priv->proxy, &win, priv->cancellable, &error)) { g_warning ("Failed to get active window: %s", error ? error->message : ""); g_error_free (error); track_ptr (BAMF_TYPE_WINDOW, NULL, (gpointer *) &priv->active_window); return NULL; } BamfFactory *factory = _bamf_factory_get_default (); view = _bamf_factory_view_for_path_type (factory, win, BAMF_FACTORY_WINDOW); g_free (win); if (!BAMF_IS_WINDOW (view)) view = NULL; track_ptr (BAMF_TYPE_WINDOW, view, (gpointer *) &priv->active_window); return priv->active_window; } /** * bamf_matcher_get_window_for_xid: * @matcher: a #BamfMatcher * @xid: The X11 Window ID to search for * * Used to fetch the #BamfWindow that wraps the given @window. * * Returns: (transfer none): The #BamfWindow representing the xid passed, or NULL if none exists. */ BamfWindow * bamf_matcher_get_window_for_xid (BamfMatcher *matcher, guint32 xid) { BamfWindow *window; BamfApplication *app; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); window = _bamf_factory_window_for_xid (_bamf_factory_get_default (), xid); if (BAMF_IS_WINDOW (window)) return window; app = bamf_matcher_get_application_for_xid (matcher, xid); if (BAMF_IS_APPLICATION (app)) window = bamf_application_get_window_for_xid (app, xid); return BAMF_IS_WINDOW (window) ? window : NULL; } /** * bamf_matcher_get_application_for_window: * @matcher: a #BamfMatcher * @window: The window to look for * * Used to fetch the #BamfApplication containing the passed window. * * Returns: (transfer none): The #BamfApplication representing the xid passed, or NULL if none exists. */ BamfApplication * bamf_matcher_get_application_for_window (BamfMatcher *matcher, BamfWindow *window) { g_return_val_if_fail (BAMF_IS_WINDOW (window), NULL); return bamf_matcher_get_application_for_xid (matcher, bamf_window_get_xid(window)); } /** * bamf_matcher_get_application_for_xid: * @matcher: a #BamfMatcher * @xid: The XID to search for * * Used to fetch the #BamfApplication containing the passed xid. * * Returns: (transfer none): The #BamfApplication representing the xid passed, or NULL if none exists. */ BamfApplication * bamf_matcher_get_application_for_xid (BamfMatcher *matcher, guint32 xid) { BamfMatcherPrivate *priv; BamfView *view; BamfFactory *factory; char *app = NULL; GError *error = NULL; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); priv = matcher->priv; factory = _bamf_factory_get_default (); view = (BamfView*) _bamf_factory_app_for_xid (factory, xid); if (BAMF_IS_APPLICATION (view)) return BAMF_APPLICATION (view); if (!_bamf_dbus_matcher_call_application_for_xid_sync (priv->proxy, xid, &app, priv->cancellable, &error)) { g_warning ("Failed to get application for xid %u: %s", xid, error ? error->message : ""); g_error_free (error); return NULL; } view = _bamf_factory_view_for_path_type (factory, app, BAMF_FACTORY_APPLICATION); g_free (app); if (!BAMF_IS_APPLICATION (view)) return NULL; return BAMF_APPLICATION (view); } gboolean bamf_matcher_application_is_running (BamfMatcher *matcher, const gchar *app) { BamfMatcherPrivate *priv; BamfApplication *view; gboolean running = FALSE; GError *error = NULL; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), FALSE); priv = matcher->priv; view = _bamf_factory_app_for_file (_bamf_factory_get_default (), app, FALSE); if (BAMF_IS_APPLICATION (view)) return bamf_view_is_running (BAMF_VIEW (view)); if (!_bamf_dbus_matcher_call_application_is_running_sync (priv->proxy, app ? app : "", &running, priv->cancellable, &error)) { g_warning ("Failed to fetch running status: %s", error ? error->message : ""); g_error_free (error); return FALSE; } return running; } /** * bamf_matcher_get_applications: * @matcher: a #BamfMatcher * * Used to fetch all #BamfApplication's running or not. Application authors who wish to only * see running applications should use bamf_matcher_get_running_applications instead. The reason * this method is needed is bamf will occasionally track applications which are not currently * running for nefarious purposes. * * Returns: (element-type Bamf.Application) (transfer container): A list of #BamfApplication's. */ GList * bamf_matcher_get_applications (BamfMatcher *matcher) { BamfMatcherPrivate *priv; BamfView *view; char **array = NULL; int i, len; GList *result = NULL; GError *error = NULL; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); priv = matcher->priv; if (!_bamf_dbus_matcher_call_application_paths_sync (priv->proxy, &array, priv->cancellable, &error)) { g_warning ("Failed to fetch applications paths: %s", error ? error->message : ""); g_error_free (error); return NULL; } if (!array) return NULL; BamfFactory *factory = _bamf_factory_get_default (); len = g_strv_length (array); for (i = len-1; i >= 0; --i) { view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_APPLICATION); if (BAMF_IS_APPLICATION (view)) { if (!g_list_find (result, view)) result = g_list_prepend (result, view); } } g_strfreev (array); return result; } /** * bamf_matcher_get_windows: * @matcher: a #BamfMatcher * * Used to fetch all windows that BAMF knows about. * * Returns: (element-type Bamf.Window) (transfer container): A list of #BamfWindow's. */ GList * bamf_matcher_get_windows (BamfMatcher *matcher) { BamfMatcherPrivate *priv; BamfView *view; char **array = NULL; int i, len; GList *result = NULL; GError *error = NULL; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); priv = matcher->priv; if (!_bamf_dbus_matcher_call_window_paths_sync (priv->proxy, &array, priv->cancellable, &error)) { g_warning ("Failed to fetch windows paths: %s", error ? error->message : ""); g_error_free (error); return NULL; } if (!array) return NULL; BamfFactory *factory = _bamf_factory_get_default (); len = g_strv_length (array); for (i = len-1; i >= 0; --i) { view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_WINDOW); if (BAMF_IS_WINDOW (view)) result = g_list_prepend (result, view); } g_strfreev (array); return result; } /** * bamf_matcher_get_window_stack_for_monitor: * @matcher: a #BamfMatcher * @monitor: the monitor you want the stack from, negative value to get all * * Used to fetch all windows that BAMF knows about in the requested screen, * in stacking bottom-to-top order. If the @monitor is set to a negative value, * then it fetches all the available windows in all monitors. * * Returns: (element-type Bamf.Window) (transfer container): A list of #BamfWindow's. */ GList * bamf_matcher_get_window_stack_for_monitor (BamfMatcher *matcher, gint monitor) { BamfMatcherPrivate *priv; BamfView *view; char **array = NULL; int i, len; GList *result = NULL; GError *error = NULL; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); priv = matcher->priv; if (!_bamf_dbus_matcher_call_window_stack_for_monitor_sync (priv->proxy, monitor, &array, priv->cancellable, &error)) { g_warning ("Failed to fetch paths: %s", error ? error->message : ""); g_error_free (error); return NULL; } if (!array) return NULL; BamfFactory *factory = _bamf_factory_get_default (); len = g_strv_length (array); for (i = len-1; i >= 0; --i) { view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_WINDOW); if (BAMF_IS_WINDOW (view)) result = g_list_prepend (result, view); } g_strfreev (array); return result; } /** * bamf_matcher_register_favorites: * @matcher: a #BamfMatcher * @favorites: (array): an array of strings, each containing an absolute path to a .desktop file * * Used to effect how bamf performs matching. Desktop files passed to this method will * be prefered by bamf to system desktop files. */ void bamf_matcher_register_favorites (BamfMatcher *matcher, const gchar **favorites) { BamfMatcherPrivate *priv; GError *error = NULL; g_return_if_fail (BAMF_IS_MATCHER (matcher)); g_return_if_fail (favorites); priv = matcher->priv; if (!_bamf_dbus_matcher_call_register_favorites_sync (priv->proxy, favorites, priv->cancellable, &error)) { g_warning ("Failed to register favorites: %s", error ? error->message : ""); g_error_free (error); } } /** * bamf_matcher_get_running_applications: * @matcher: a #BamfMatcher * * Used to fetch all #BamfApplication's which are running. * * Returns: (element-type Bamf.Application) (transfer container): A list of #BamfApplication's. */ GList * bamf_matcher_get_running_applications (BamfMatcher *matcher) { BamfMatcherPrivate *priv; BamfView *view; char **array = NULL; int i, len; GList *result = NULL; GError *error = NULL; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); priv = matcher->priv; if (!_bamf_dbus_matcher_call_running_applications_sync (priv->proxy, &array, priv->cancellable, &error)) { g_warning ("Failed to get running applications: %s", error ? error->message : ""); g_error_free (error); return NULL; } if (!array) return NULL; BamfFactory *factory = _bamf_factory_get_default (); len = g_strv_length (array); for (i = len-1; i >= 0; --i) { view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_APPLICATION); if (BAMF_IS_APPLICATION (view)) result = g_list_prepend (result, view); } g_strfreev (array); return result; } /** * bamf_matcher_get_tabs: * @matcher: a #BamfMatcher * * Used to fetch all #BamfView's representing tabs. Currently unused. * * Returns: (element-type Bamf.Tab) (transfer container): A list of #BamfTab's. */ GList * bamf_matcher_get_tabs (BamfMatcher *matcher) { BamfMatcherPrivate *priv; BamfView *view; char **array = NULL; int i, len; GList *result = NULL; GError *error = NULL; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); priv = matcher->priv; if (!_bamf_dbus_matcher_call_tab_paths_sync (priv->proxy, &array, priv->cancellable, &error)) { g_warning ("Failed to get tabs: %s", error ? error->message : ""); g_error_free (error); return NULL; } g_return_val_if_fail (array, NULL); BamfFactory *factory = _bamf_factory_get_default (); len = g_strv_length (array); for (i = len-1; i >= 0; --i) { view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_TAB); if (BAMF_IS_TAB (view)) result = g_list_prepend (result, view); } g_strfreev (array); return result; } /** * bamf_matcher_get_xids_for_application: * @matcher: a #BamfMatcher * * Used to fetch all xid's associated with an application. Useful for performing window * * * Returns: (element-type guint32) (transfer full): A list of xids. */ GArray * bamf_matcher_get_xids_for_application (BamfMatcher *matcher, const gchar *application) { BamfMatcherPrivate *priv; GArray *result = NULL; GVariant *xids = NULL; GVariantIter *iter; GError *error = NULL; guint32 xid = 0; g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); priv = matcher->priv; if (!_bamf_dbus_matcher_call_xids_for_application_sync (priv->proxy, application, &xids, priv->cancellable, &error)) { g_warning ("Failed to get xids: %s", error ? error->message : ""); g_error_free (error); return NULL; } g_return_val_if_fail (xids, NULL); g_return_val_if_fail (g_variant_type_equal (g_variant_get_type (xids), G_VARIANT_TYPE ("au")), NULL); result = g_array_new (FALSE, TRUE, sizeof (guint32)); g_variant_get (xids, "au", &iter); while (g_variant_iter_loop (iter, "u", &xid)) { g_array_append_val (result, xid); } g_variant_iter_free (iter); g_variant_unref (xids); return result; } /** * bamf_matcher_get_application_for_desktop_file: * @matcher: a #BamfMatcher * @desktop_file_path: Path to the desktop file * @create_if_not_found: Create a #BamfApplication if one isn't found * * Returns: (transfer none): A #BamfApplication for given desktop file. */ BamfApplication * bamf_matcher_get_application_for_desktop_file (BamfMatcher *matcher, const gchar *desktop_file_path, gboolean create_if_not_found) { BamfApplication *app; const gchar ** favs; app = _bamf_factory_app_for_file (_bamf_factory_get_default (), desktop_file_path, create_if_not_found); if (app) { favs = g_new0 (const gchar *, 2); favs[0] = desktop_file_path; bamf_matcher_register_favorites (matcher, favs); g_free (favs); } return app; } ./lib/libbamf/bamf-matcher.h0000644000004100000410000001130414203512426016102 0ustar www-datawww-data/* * Copyright 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef _BAMF_MATCHER_H_ #define _BAMF_MATCHER_H_ #include #include #include G_BEGIN_DECLS #define BAMF_TYPE_MATCHER (bamf_matcher_get_type ()) #define BAMF_MATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\ BAMF_TYPE_MATCHER, BamfMatcher)) #define BAMF_MATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\ BAMF_TYPE_MATCHER, BamfMatcherClass)) #define BAMF_IS_MATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ BAMF_TYPE_MATCHER)) #define BAMF_IS_MATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ BAMF_TYPE_MATCHER)) #define BAMF_MATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ BAMF_TYPE_MATCHER, BamfMatcherClass)) #define BAMF_MATCHER_SIGNAL_VIEW_OPENED "view-opened" #define BAMF_MATCHER_SIGNAL_VIEW_CLOSED "view-closed" #define BAMF_MATCHER_SIGNAL_ACTIVE_APPLICATION_CHANGED "active-application-changed" #define BAMF_MATCHER_SIGNAL_ACTIVE_WINDOW_CHANGED "active-window-changed" #define BAMF_MATCHER_SIGNAL_STACKING_ORDER_CHANGED "stacking-order-changed" typedef struct _BamfMatcher BamfMatcher; typedef struct _BamfMatcherClass BamfMatcherClass; typedef struct _BamfMatcherPrivate BamfMatcherPrivate; struct _BamfMatcher { GObject parent; BamfMatcherPrivate *priv; }; struct _BamfMatcherClass { GObjectClass parent_class; /*< private >*/ void (*_matcher_padding1) (void); void (*_matcher_padding2) (void); void (*_matcher_padding3) (void); void (*_matcher_padding4) (void); void (*_matcher_padding5) (void); void (*_matcher_padding6) (void); }; GType bamf_matcher_get_type (void) G_GNUC_CONST; BamfMatcher * bamf_matcher_get_default (void); BamfApplication * bamf_matcher_get_active_application (BamfMatcher *matcher); BamfWindow * bamf_matcher_get_active_window (BamfMatcher *matcher); BamfWindow * bamf_matcher_get_window_for_xid (BamfMatcher *matcher, guint32 xid); BamfApplication * bamf_matcher_get_application_for_xid (BamfMatcher *matcher, guint32 xid); BamfApplication * bamf_matcher_get_application_for_window (BamfMatcher *matcher, BamfWindow *window); gboolean bamf_matcher_application_is_running (BamfMatcher *matcher, const gchar *desktop_file); GList * bamf_matcher_get_applications (BamfMatcher *matcher); void bamf_matcher_register_favorites (BamfMatcher *matcher, const gchar **favorites); GList * bamf_matcher_get_running_applications (BamfMatcher *matcher); GList * bamf_matcher_get_tabs (BamfMatcher *matcher); GArray * bamf_matcher_get_xids_for_application (BamfMatcher *matcher, const gchar *desktop_file); GList * bamf_matcher_get_windows (BamfMatcher *matcher); GList * bamf_matcher_get_window_stack_for_monitor (BamfMatcher *matcher, gint monitor); BamfApplication * bamf_matcher_get_application_for_desktop_file (BamfMatcher *matcher, const gchar *desktop_file_path, gboolean create_if_not_found); G_END_DECLS #endif ./lib/libbamf/bamf-application.h0000644000004100000410000000567514203512426017000 0ustar www-datawww-data/* * Copyright 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef _BAMF_APPLICATION_H_ #define _BAMF_APPLICATION_H_ #include #include #include G_BEGIN_DECLS #define BAMF_TYPE_APPLICATION (bamf_application_get_type ()) #define BAMF_APPLICATION_SIGNAL_DESKTOP_FILE_UPDATED "desktop-file-updated" #define BAMF_APPLICATION_SIGNAL_WINDOW_ADDED "window-added" #define BAMF_APPLICATION_SIGNAL_WINDOW_REMOVED "window-removed" G_DECLARE_DERIVABLE_TYPE (BamfApplication, bamf_application, BAMF, APPLICATION, BamfView); struct _BamfApplicationClass { BamfViewClass parent_class; /*< private >*/ void (*_application_padding1) (void); void (*_application_padding2) (void); void (*_application_padding3) (void); void (*_application_padding4) (void); void (*_application_padding5) (void); void (*_application_padding6) (void); }; const gchar * bamf_application_get_application_type (BamfApplication *application); const gchar * bamf_application_get_desktop_file (BamfApplication *application); gchar ** bamf_application_get_supported_mime_types (BamfApplication *application); GList * bamf_application_get_windows (BamfApplication *application); GArray * bamf_application_get_xids (BamfApplication *application); BamfView * bamf_application_get_focusable_child (BamfApplication *application); gboolean bamf_application_get_show_menu_stubs (BamfApplication *application); BamfWindow * bamf_application_get_window_for_xid (BamfApplication *application, guint32 xid); /* Deprecated symbols */ G_GNUC_DEPRECATED gboolean bamf_application_get_application_menu (BamfApplication *application, gchar **name, gchar **object_path); G_END_DECLS #endif ./lib/libbamf/bamf-tab.h0000644000004100000410000000462314203512426015233 0ustar www-datawww-data/* * Copyright 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef __BAMF_TAB_H__ #define __BAMF_TAB_H__ #include #include G_BEGIN_DECLS #define BAMF_TYPE_TAB (bamf_tab_get_type ()) G_DECLARE_DERIVABLE_TYPE (BamfTab, bamf_tab, BAMF, TAB, BamfView); struct _BamfTabClass { BamfViewClass parent_class; const gchar * (*get_desktop_name) (BamfTab *self); const gchar * (*get_location) (BamfTab *self); guint64 (*get_xid) (BamfTab *self); gboolean (*get_is_foreground_tab) (BamfTab *self); /*< private >*/ void (*_tab_padding1) (void); void (*_tab_padding2) (void); void (*_tab_padding3) (void); void (*_tab_padding4) (void); }; typedef void (*BamfTabPreviewReadyCallback) (BamfTab *self, const gchar *preview_data, gpointer user_data); gboolean bamf_tab_raise (BamfTab *self); gboolean bamf_tab_close (BamfTab *self); void bamf_tab_request_preview (BamfTab *self, BamfTabPreviewReadyCallback callback, gpointer user_data); const gchar *bamf_tab_get_desktop_name (BamfTab *self); const gchar *bamf_tab_get_location (BamfTab *self); guint64 bamf_tab_get_xid (BamfTab *self); gboolean bamf_tab_get_is_foreground_tab (BamfTab *self); G_END_DECLS #endif /* __BAMF_TAB_H__ */ ./lib/libbamf/bamf-view-private.h0000644000004100000410000000340214203512426017101 0ustar www-datawww-data/* * Copyright (C) 2010-2013 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Jason Smith * Marco Trevisan (Treviño) * */ #ifndef _BAMF_VIEW_PRIVATE_H_ #define _BAMF_VIEW_PRIVATE_H_ #include #include "bamf-application.h" #include "bamf-tab.h" #include "bamf-view.h" #include "bamf-window.h" #define CANCELLABLE(view) _bamf_view_get_cancellable (BAMF_VIEW (view)) BamfApplication * bamf_application_new (const char *path); BamfApplication * bamf_application_new_favorite (const char *favorite_path); BamfTab * bamf_tab_new (const char *path); BamfWindow * bamf_window_new (const char *path); void _bamf_view_set_path (BamfView *view, const char *dbus_path); const char * _bamf_view_get_path (BamfView *view); gboolean _bamf_view_remote_ready (BamfView *view); void _bamf_view_reset_flags (BamfView *view); void _bamf_view_set_cached_name (BamfView *view, const char *name); void _bamf_view_set_cached_icon (BamfView *view, const char *icon); void _bamf_view_set_closed (BamfView *view, gboolean closed); GCancellable * _bamf_view_get_cancellable (BamfView *view); #endif ./lib/libbamf/bamf-view.h0000644000004100000410000001161414203512426015435 0ustar www-datawww-data/* * Copyright 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #ifndef _BAMF_VIEW_H_ #define _BAMF_VIEW_H_ #include G_BEGIN_DECLS #define BAMF_TYPE_VIEW (bamf_view_get_type ()) #define BAMF_VIEW_SIGNAL_ACTIVE_CHANGED "active-changed" #define BAMF_VIEW_SIGNAL_RUNNING_CHANGED "running-changed" #define BAMF_VIEW_SIGNAL_STARTING_CHANGED "starting-changed" #define BAMF_VIEW_SIGNAL_URGENT_CHANGED "urgent-changed" #define BAMF_VIEW_SIGNAL_USER_VISIBLE_CHANGED "user-visible-changed" #define BAMF_VIEW_SIGNAL_NAME_CHANGED "name-changed" #define BAMF_VIEW_SIGNAL_ICON_CHANGED "icon-changed" #define BAMF_VIEW_SIGNAL_CHILD_ADDED "child-added" #define BAMF_VIEW_SIGNAL_CHILD_REMOVED "child-removed" #define BAMF_VIEW_SIGNAL_CHILD_MOVED "child-moved" #define BAMF_VIEW_SIGNAL_CLOSED "closed" typedef enum { BAMF_CLICK_BEHAVIOR_NONE, BAMF_CLICK_BEHAVIOR_OPEN, BAMF_CLICK_BEHAVIOR_FOCUS, BAMF_CLICK_BEHAVIOR_FOCUS_ALL, BAMF_CLICK_BEHAVIOR_MINIMIZE, BAMF_CLICK_BEHAVIOR_RESTORE, BAMF_CLICK_BEHAVIOR_RESTORE_ALL, BAMF_CLICK_BEHAVIOR_PICKER, } BamfClickBehavior; G_DECLARE_DERIVABLE_TYPE (BamfView, bamf_view, BAMF, VIEW, GInitiallyUnowned); struct _BamfViewClass { GInitiallyUnownedClass parent_class; GList * (*get_children) (BamfView *view); gboolean (*is_active) (BamfView *view); gboolean (*is_running) (BamfView *view); gboolean (*is_urgent) (BamfView *view); gboolean (*is_user_visible) (BamfView *view); gchar * (*get_name) (BamfView *view); gchar * (*get_icon) (BamfView *view); const gchar * (*view_type) (BamfView *view); void (*set_path) (BamfView *view, const gchar *path); void (*set_sticky) (BamfView *view, gboolean value); BamfClickBehavior (*click_behavior) (BamfView *view); /*< signals >*/ void (*active_changed) (BamfView *view, gboolean active); void (*closed) (BamfView *view); void (*child_added) (BamfView *view, BamfView *child); void (*child_removed) (BamfView *view, BamfView *child); void (*running_changed) (BamfView *view, gboolean running); void (*urgent_changed) (BamfView *view, gboolean urgent); void (*user_visible_changed) (BamfView *view, gboolean user_visible); void (*name_changed) (BamfView *view, gchar* old_name, gchar* new_name); void (*icon_changed) (BamfView *view, gchar* icon); void (*child_moved) (BamfView *view, BamfView *child); gboolean (*is_starting) (BamfView *view); void (*starting_changed) (BamfView *view, gboolean starting); /*< private >*/ void (*_view_padding1) (void); }; GList * bamf_view_get_children (BamfView *view); GList * bamf_view_peek_children (BamfView *view); gboolean bamf_view_has_child (BamfView *view, BamfView *child); gboolean bamf_view_is_closed (BamfView *view); gboolean bamf_view_is_active (BamfView *view); gboolean bamf_view_is_starting (BamfView *view); gboolean bamf_view_is_running (BamfView *view); gboolean bamf_view_is_urgent (BamfView *view); gboolean bamf_view_is_user_visible (BamfView *view); gchar * bamf_view_get_name (BamfView *view); gchar * bamf_view_get_icon (BamfView *view); const gchar * bamf_view_get_view_type (BamfView *view); void bamf_view_set_sticky (BamfView *view, gboolean value); gboolean bamf_view_is_sticky (BamfView *view); /* Deprecated symbols */ G_GNUC_DEPRECATED BamfClickBehavior bamf_view_get_click_suggestion (BamfView *view); G_GNUC_DEPRECATED_FOR (bamf_view_is_user_visible) gboolean bamf_view_user_visible (BamfView *view); G_END_DECLS #endif ./lib/libbamf/bamf-factory.c0000644000004100000410000003415314203512426016130 0ustar www-datawww-data/* * Copyright 2010-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) * */ /** * SECTION:bamf-factory * @short_description: The base class for all factorys * * #BamfFactory is the base class that all factorys need to derive from. */ #if HAVE_CONFIG_H #include #endif #include #include "bamf-factory.h" #include "bamf-application-private.h" #include "bamf-view-private.h" struct _BamfFactoryPrivate { GHashTable *open_views; GList *allocated_views; }; G_DEFINE_TYPE_WITH_PRIVATE (BamfFactory, bamf_factory, G_TYPE_OBJECT); static BamfFactory *static_factory = NULL; static void on_view_weak_unref (BamfFactory *self, BamfView *view_was_here); static void on_view_closed (BamfView *view, BamfFactory *self); static void bamf_factory_dispose (GObject *object) { GList *l, *next; BamfFactory *self = BAMF_FACTORY (object); if (self->priv->allocated_views) { for (l = self->priv->allocated_views, next = NULL; l; l = next) { g_object_weak_unref (G_OBJECT (l->data), (GWeakNotify) on_view_weak_unref, self); g_signal_handlers_disconnect_by_func (l->data, on_view_closed, self); next = l->next; g_list_free1 (l); } self->priv->allocated_views = NULL; } if (self->priv->open_views) { g_hash_table_remove_all (self->priv->open_views); self->priv->open_views = NULL; } G_OBJECT_CLASS (bamf_factory_parent_class)->dispose (object); } static void bamf_factory_finalize (GObject *object) { BamfFactory *self = BAMF_FACTORY (object); if (self->priv->open_views) { g_hash_table_destroy (self->priv->open_views); self->priv->open_views = NULL; } static_factory = NULL; G_OBJECT_CLASS (bamf_factory_parent_class)->finalize (object); } static void bamf_factory_class_init (BamfFactoryClass *klass) { GObjectClass *obj_class = G_OBJECT_CLASS (klass); obj_class->dispose = bamf_factory_dispose; obj_class->finalize = bamf_factory_finalize; } static void bamf_factory_init (BamfFactory *self) { self->priv = bamf_factory_get_instance_private (self); self->priv->open_views = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); } static void on_view_closed (BamfView *view, BamfFactory *self) { const char *path; gboolean removed; removed = FALSE; path = _bamf_view_get_path (view); g_signal_handlers_disconnect_by_func (view, on_view_closed, self); if (path) { removed = g_hash_table_remove (self->priv->open_views, path); } if (G_UNLIKELY (!removed)) { /* Unlikely to happen, but who knows... */ GHashTableIter iter; gpointer value; g_hash_table_iter_init (&iter, self->priv->open_views); while (g_hash_table_iter_next (&iter, NULL, &value)) { if (value == view) { g_hash_table_iter_remove (&iter); removed = TRUE; break; } } } } static void on_view_weak_unref (BamfFactory *self, BamfView *view_was_here) { self->priv->allocated_views = g_list_remove (self->priv->allocated_views, view_was_here); } static void bamf_factory_track_view (BamfFactory *self, BamfView *view) { g_return_if_fail (BAMF_IS_VIEW (view)); if (g_list_find (self->priv->allocated_views, view)) return; g_object_weak_ref (G_OBJECT (view), (GWeakNotify) on_view_weak_unref, self); self->priv->allocated_views = g_list_prepend (self->priv->allocated_views, view); } static void bamf_factory_register_view (BamfFactory *self, BamfView *view, const char *path) { g_return_if_fail (BAMF_IS_VIEW (view)); g_return_if_fail (path != NULL); g_object_ref_sink (view); g_hash_table_insert (self->priv->open_views, g_strdup (path), view); g_signal_connect_after (G_OBJECT (view), BAMF_VIEW_SIGNAL_CLOSED, G_CALLBACK (on_view_closed), self); } BamfWindow * _bamf_factory_window_for_xid (BamfFactory * factory, guint32 xid) { BamfWindow *result = NULL, *win; GList *l; for (l = factory->priv->allocated_views; l; l = l->next) { if (!BAMF_IS_WINDOW (l->data)) continue; if (bamf_view_is_closed (l->data)) continue; win = BAMF_WINDOW (l->data); if (bamf_window_get_xid (win) == xid) { result = win; break; } } return result; } BamfApplication * _bamf_factory_app_for_file (BamfFactory * factory, const char * path, gboolean create) { BamfApplication *result = NULL, *app; GList *l; /* check if result is available in known allocated_views */ for (l = factory->priv->allocated_views; l; l = l->next) { if (!BAMF_IS_APPLICATION (l->data)) continue; app = BAMF_APPLICATION (l->data); if (g_strcmp0 (bamf_application_get_desktop_file (app), path) == 0) { result = app; break; } } /* else create new */ if (!result && create) { /* delay registration until match time */ result = bamf_application_new_favorite (path); if (BAMF_IS_APPLICATION (result)) { bamf_factory_track_view (factory, BAMF_VIEW (result)); } } return result; } BamfApplication * _bamf_factory_app_for_xid (BamfFactory * factory, guint32 xid) { BamfApplication *result = NULL, *app; GList *l, *local_children; for (l = factory->priv->allocated_views; l; l = l->next) { if (!BAMF_IS_APPLICATION (l->data)) continue; if (bamf_view_is_closed (l->data)) continue; app = BAMF_APPLICATION (l->data); local_children = _bamf_application_get_cached_xids (app); if (g_list_find (local_children, GUINT_TO_POINTER (xid))) { result = app; break; } } return result; } static BamfFactoryViewType compute_factory_type_by_str (const char *type) { BamfFactoryViewType factory_type = BAMF_FACTORY_NONE; if (type && type[0] != '\0') { if (g_strcmp0 (type, "window") == 0) { factory_type = BAMF_FACTORY_WINDOW; } else if (g_strcmp0 (type, "application") == 0) { factory_type = BAMF_FACTORY_APPLICATION; } else if (g_strcmp0 (type, "tab") == 0) { factory_type = BAMF_FACTORY_TAB; } else if (g_strcmp0 (type, "view") == 0) { factory_type = BAMF_FACTORY_VIEW; } } return factory_type; } BamfView * _bamf_factory_view_for_path (BamfFactory * factory, const char * path) { return _bamf_factory_view_for_path_type (factory, path, BAMF_FACTORY_NONE); } BamfView * _bamf_factory_view_for_path_type_str (BamfFactory * factory, const char * path, const char * type) { g_return_val_if_fail (BAMF_IS_FACTORY (factory), NULL); BamfFactoryViewType factory_type = compute_factory_type_by_str (type); return _bamf_factory_view_for_path_type (factory, path, factory_type); } BamfView * _bamf_factory_view_for_path_type (BamfFactory * factory, const char * path, BamfFactoryViewType type) { GHashTable *views; BamfView *view; BamfDBusItemView *vproxy; GList *l; g_return_val_if_fail (BAMF_IS_FACTORY (factory), NULL); if (!path || path[0] == '\0') return NULL; views = factory->priv->open_views; view = g_hash_table_lookup (views, path); if (BAMF_IS_VIEW (view)) return view; if (type == BAMF_FACTORY_NONE) { vproxy = _bamf_dbus_item_view_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, BAMF_DBUS_SERVICE_NAME, path, NULL, NULL); if (G_IS_DBUS_PROXY (vproxy)) { char *type_str = NULL; g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (vproxy), BAMF_DBUS_DEFAULT_TIMEOUT); _bamf_dbus_item_view_call_view_type_sync (vproxy, &type_str, NULL, NULL); type = compute_factory_type_by_str (type_str); g_free (type_str); g_object_unref (vproxy); } } switch (type) { case BAMF_FACTORY_VIEW: view = g_object_new (BAMF_TYPE_VIEW, NULL); break; case BAMF_FACTORY_WINDOW: view = BAMF_VIEW (bamf_window_new (path)); break; case BAMF_FACTORY_APPLICATION: view = BAMF_VIEW (bamf_application_new (path)); break; case BAMF_FACTORY_TAB: view = BAMF_VIEW (bamf_tab_new (path)); break; case BAMF_FACTORY_NONE: view = NULL; break; } BamfView *matched_view = NULL; /* handle case where another allocated (but closed) view exists and the new * one matches it, so that we can reuse it. */ if (BAMF_IS_APPLICATION (view)) { const char *local_desktop_file = bamf_application_get_desktop_file (BAMF_APPLICATION (view)); GList *local_children = _bamf_application_get_cached_xids (BAMF_APPLICATION (view)); char *local_name = bamf_view_get_name (view); gboolean matched_by_name = FALSE; for (l = factory->priv->allocated_views; l; l = l->next) { if (!BAMF_IS_APPLICATION (l->data)) continue; if (!bamf_view_is_closed (l->data)) continue; BamfView *list_view = BAMF_VIEW (l->data); BamfApplication *list_app = BAMF_APPLICATION (l->data); const char *list_desktop_file = bamf_application_get_desktop_file (list_app); /* We try to match applications by desktop files */ if (local_desktop_file && g_strcmp0 (local_desktop_file, list_desktop_file) == 0) { matched_view = list_view; break; } /* If the primary search doesn't give out any result, we fallback * to children window comparison */ if (!list_desktop_file) { GList *list_children, *ll; list_children = _bamf_application_get_cached_xids (list_app); for (ll = local_children; ll; ll = ll->next) { if (g_list_find (list_children, ll->data)) { /* Not stopping the parent loop here is intended, as we * can still find a better result in next iterations */ matched_view = list_view; break; } } if ((!matched_view || matched_by_name) && local_name && local_name[0] != '\0') { char *list_name = bamf_view_get_name (list_view); if (g_strcmp0 (local_name, list_name) == 0) { if (!matched_by_name) { matched_view = list_view; matched_by_name = TRUE; } else { /* We have already matched an app by its name, this * means that there are two apps with the same name. * It's safer to ignore both, then. */ matched_view = NULL; } } g_free (list_name); } } } g_free (local_name); } else if (BAMF_IS_WINDOW (view)) { guint32 local_xid = bamf_window_get_xid (BAMF_WINDOW (view)); for (l = factory->priv->allocated_views; l; l = l->next) { if (!BAMF_IS_WINDOW (l->data)) continue; if (!bamf_view_is_closed (l->data)) continue; BamfView *list_view = BAMF_VIEW (l->data); BamfWindow *list_win = BAMF_WINDOW (l->data); guint32 list_xid = bamf_window_get_xid (list_win); /* We try to match windows by xid */ if (local_xid != 0 && local_xid == list_xid) { matched_view = list_view; break; } } } if (matched_view) { if (view) { /* We don't need anymore the view we've just created, let's forget it */ g_object_unref (view); } /* If we are here, we're pretty sure that the view is not in the * open_views, hash-table (since it has been closed) so we can safely * re-register it here again. */ view = matched_view; _bamf_view_set_path (view, path); bamf_factory_register_view (factory, view, path); } else if (view) { /* It's the first time we register this view, we also have to track it, then */ bamf_factory_track_view (factory, view); bamf_factory_register_view (factory, view, path); } return view; } BamfFactory * _bamf_factory_get_default (void) { if (BAMF_IS_FACTORY (static_factory)) return static_factory; static_factory = (BamfFactory *) g_object_new (BAMF_TYPE_FACTORY, NULL); return static_factory; } ./lib/libbamf/bamf-control.c0000644000004100000410000001240014203512426016130 0ustar www-datawww-data/* * Copyright 2010-2012 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ /** * SECTION:bamf-control * @short_description: The base class for all controls * * #BamfControl is the base class that all controls need to derive from. */ #if HAVE_CONFIG_H #include #endif #include #include "bamf-control.h" #include "bamf-view-private.h" struct _BamfControlPrivate { BamfDBusControl *proxy; }; G_DEFINE_TYPE_WITH_PRIVATE (BamfControl, bamf_control, G_TYPE_OBJECT); /* Globals */ static BamfControl * default_control = NULL; /* Forwards */ /* * GObject stuff */ static void bamf_control_dispose (GObject *object) { BamfControl *self = BAMF_CONTROL (object); if (self->priv->proxy) { g_object_unref (self->priv->proxy); self->priv->proxy = NULL; } G_OBJECT_CLASS (bamf_control_parent_class)->dispose (object); } static void bamf_control_finalize (GObject *object) { default_control = NULL; G_OBJECT_CLASS (bamf_control_parent_class)->finalize (object); } static void bamf_control_class_init (BamfControlClass *klass) { GObjectClass *obj_class = G_OBJECT_CLASS (klass); obj_class->dispose = bamf_control_dispose; obj_class->finalize = bamf_control_finalize; obj_class->dispose = bamf_control_dispose; } static void bamf_control_init (BamfControl *self) { BamfControlPrivate *priv; GError *error = NULL; priv = self->priv = bamf_control_get_instance_private (self); priv->proxy = _bamf_dbus_control_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, BAMF_DBUS_SERVICE_NAME, BAMF_DBUS_CONTROL_PATH, NULL, &error); if (error) { g_error ("Unable to get "BAMF_DBUS_CONTROL_PATH" controller: %s", error->message); g_error_free (error); return; } g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (priv->proxy), BAMF_DBUS_DEFAULT_TIMEOUT); } /** * bamf_control_get_default: * * Returns: (transfer full): The default #BamfControl reference. */ BamfControl * bamf_control_get_default (void) { if (BAMF_IS_CONTROL (default_control)) return g_object_ref (default_control); default_control = g_object_new (BAMF_TYPE_CONTROL, NULL); return default_control; } void bamf_control_insert_desktop_file (BamfControl *control, const gchar *desktop_file) { BamfControlPrivate *priv; GError *error = NULL; g_return_if_fail (BAMF_IS_CONTROL (control)); priv = control->priv; if (!_bamf_dbus_control_call_insert_desktop_file_sync (priv->proxy, desktop_file, NULL, &error)) { g_warning ("Failed to insert desktop file: %s", error->message); g_error_free (error); } } void bamf_control_create_local_desktop_file (BamfControl *control, BamfApplication *app) { BamfControlPrivate *priv; const gchar *app_path; GError *error = NULL; g_return_if_fail (BAMF_IS_CONTROL (control)); g_return_if_fail (BAMF_IS_APPLICATION (app)); priv = control->priv; app_path = _bamf_view_get_path (BAMF_VIEW (app)); if (!app_path) return; if (!_bamf_dbus_control_call_create_local_desktop_file_sync (priv->proxy, app_path, NULL, &error)) { g_warning ("Failed to create local desktop file: %s", error->message); g_error_free (error); } } void bamf_control_register_application_for_pid (BamfControl *control, const gchar *desktop_file, gint32 pid) { BamfControlPrivate *priv; GError *error = NULL; g_return_if_fail (BAMF_IS_CONTROL (control)); priv = control->priv; if (!_bamf_dbus_control_call_register_application_for_pid_sync (priv->proxy, desktop_file, pid, NULL, &error)) { g_warning ("Failed to register application: %s", error->message); g_error_free (error); } } ./lib/libbamf/libbamf3.pc.in0000644000004100000410000000044414203512426016016 0ustar www-datawww-dataprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: libbamf3 Description: C Convenience library for bamf d-bus server. Version: @VERSION@ Requires: glib-2.0 gio-2.0 Libs: -L${libdir} -lbamf3 Cflags: -I${includedir}/libbamf3 -I${libdir}/libbamf3/include ./lib/libbamf/libbamf.h0000644000004100000410000000227414203512426015156 0ustar www-datawww-data/* * Copyright 2010 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * */ #ifndef __LIBBAMF_H__ #define __LIBBAMF_H__ #include #include #include #include #include #include #endif ./lib/libbamf/bamf-view.c0000644000004100000410000007323414203512426015436 0ustar www-datawww-data/* * Copyright 2010-2012 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ /** * SECTION:bamf-view * @short_description: The base class for all views * * #BamfView is the base class that all views need to derive from. */ #if HAVE_CONFIG_H #include #endif #include #include "bamf-view.h" #include "bamf-view-private.h" #include "bamf-factory.h" #include "bamf-tab.h" #include "bamf-window.h" enum { ACTIVE_CHANGED, CLOSED, CHILD_ADDED, CHILD_REMOVED, CHILD_MOVED, STARTING_CHANGED, RUNNING_CHANGED, URGENT_CHANGED, VISIBLE_CHANGED, NAME_CHANGED, ICON_CHANGED, LAST_SIGNAL }; enum { PROP_0, PROP_PATH, PROP_STARTING, PROP_RUNNING, PROP_ACTIVE, PROP_USER_VISIBLE, PROP_URGENT, PROP_LAST }; static guint view_signals[LAST_SIGNAL] = { 0 }; static GParamSpec *properties[PROP_LAST] = { 0 }; typedef struct _BamfViewPrivate { BamfDBusItemView *proxy; GCancellable *cancellable; gchar *type; gchar *cached_name; gchar *cached_icon; GList *cached_children; gboolean reload_children; gboolean is_closed; gboolean sticky; } BamfViewPrivate; G_DEFINE_TYPE_WITH_PRIVATE (BamfView, bamf_view, G_TYPE_INITIALLY_UNOWNED); static void bamf_view_unset_proxy (BamfView *self); /** * bamf_view_get_children: * @view: a #BamfView * * Note: Makes sever dbus calls the first time this is called on a view. Dbus messaging is reduced afterwards. * * Returns: (element-type Bamf.View) (transfer container): Returns a list of #BamfView which must be * freed after usage. Elements of the list are owned by bamf and should not be unreffed. */ GList * bamf_view_get_children (BamfView *view) { g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); if (BAMF_VIEW_GET_CLASS (view)->get_children) return BAMF_VIEW_GET_CLASS (view)->get_children (view); return g_list_copy (bamf_view_peek_children (view)); } /** * bamf_view_peek_children: * @view: a #BamfView * * Note: Makes sever dbus calls the first time this is called on a view. * Dbus messaging is reduced afterwards. * Since: 0.5.2 * Returns: (element-type Bamf.View) (transfer none): Returns a list of #BamfView which * is owned by the #BamfView and should not freed or modified after usage. */ GList * bamf_view_peek_children (BamfView *view) { char ** children; int i, len; GList *results = NULL; GError *error = NULL; BamfViewPrivate *priv; BamfView *child; g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); if (!_bamf_view_remote_ready (view)) return NULL; priv = bamf_view_get_instance_private (view); if (priv->cached_children || !priv->reload_children) return priv->cached_children; if (!_bamf_dbus_item_view_call_children_sync (priv->proxy, &children, CANCELLABLE (view), &error)) { g_warning ("Unable to fetch children: %s\n", error ? error->message : ""); g_error_free (error); return NULL; } if (!children) return NULL; len = g_strv_length (children); for (i = len-1; i >= 0; --i) { child = _bamf_factory_view_for_path (_bamf_factory_get_default (), children[i]); if (BAMF_IS_VIEW (child)) { results = g_list_prepend (results, g_object_ref (child)); } } if (priv->cached_children) g_list_free_full (priv->cached_children, g_object_unref); priv->reload_children = FALSE; priv->cached_children = results; return priv->cached_children; } /** * bamf_view_has_child: * @view: a #BamfView * * Returns: %TRUE whether the #BamfView @view has the specified @child. */ gboolean bamf_view_has_child (BamfView *view, BamfView *child) { GList *l; g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); g_return_val_if_fail (BAMF_IS_VIEW (child), FALSE); for (l = bamf_view_peek_children (view); l; l = l->next) { if (l->data == child) return TRUE; } return FALSE; } /** * bamf_view_is_closed: * @view: a #BamfView * * Determines if the view is closed or not. */ gboolean bamf_view_is_closed (BamfView *view) { BamfViewPrivate *priv; g_return_val_if_fail (BAMF_IS_VIEW (view), TRUE); priv = bamf_view_get_instance_private (view); return priv->is_closed; } /** * bamf_view_is_active: * @view: a #BamfView * * Determines if the view is currently active and focused by the user. Useful for an active window indicator. */ gboolean bamf_view_is_active (BamfView *view) { g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); BamfViewPrivate *priv = bamf_view_get_instance_private (view); if (BAMF_VIEW_GET_CLASS (view)->is_active) return BAMF_VIEW_GET_CLASS (view)->is_active (view); if (!_bamf_view_remote_ready (view)) return FALSE; return _bamf_dbus_item_view_get_active (priv->proxy); } /** * bamf_view_is_user_visible: * @view: a #BamfView * * Returns: a boolean useful for determining if a particular view is "user visible". User visible * is a concept relating to whether or not a window should be shown in a launcher tasklist. * * Since: 0.4.0 */ gboolean bamf_view_is_user_visible (BamfView *self) { BamfViewPrivate *priv; g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE); if (BAMF_VIEW_GET_CLASS (self)->is_user_visible) return BAMF_VIEW_GET_CLASS (self)->is_user_visible (self); if (!_bamf_view_remote_ready (self)) return FALSE; priv = bamf_view_get_instance_private (self); return _bamf_dbus_item_view_get_user_visible (priv->proxy); } /** * bamf_view_user_visible: (skip) * @view: a #BamfView * * Returns: a boolean useful for determining if a particular view is "user visible". User visible * is a concept relating to whether or not a window should be shown in a launcher tasklist. * * Deprecated: 0.4.0 */ gboolean bamf_view_user_visible (BamfView *self) { return bamf_view_is_user_visible (self); } /** * bamf_view_is_starting: * @view: a #BamfView * * Determines if the view is currently starting. Useful for the startup animation. */ gboolean bamf_view_is_starting (BamfView *self) { BamfViewPrivate *priv; g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE); if (BAMF_VIEW_GET_CLASS (self)->is_starting) return BAMF_VIEW_GET_CLASS (self)->is_starting (self); if (!_bamf_view_remote_ready (self)) return FALSE; priv = bamf_view_get_instance_private (self); return _bamf_dbus_item_view_get_starting (priv->proxy); } /** * bamf_view_is_running: * @view: a #BamfView * * Determines if the view is currently running. Useful for a running window indicator. */ gboolean bamf_view_is_running (BamfView *self) { BamfViewPrivate *priv; g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE); if (BAMF_VIEW_GET_CLASS (self)->is_running) return BAMF_VIEW_GET_CLASS (self)->is_running (self); if (!_bamf_view_remote_ready (self)) return FALSE; priv = bamf_view_get_instance_private (self); return _bamf_dbus_item_view_get_running (priv->proxy); } /** * bamf_view_is_urgent: * @view: a #BamfView * * Determines if the view is currently requiring attention. Useful for a running window indicator. */ gboolean bamf_view_is_urgent (BamfView *self) { BamfViewPrivate *priv; g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE); if (BAMF_VIEW_GET_CLASS (self)->is_urgent) return BAMF_VIEW_GET_CLASS (self)->is_urgent (self); if (!_bamf_view_remote_ready (self)) return FALSE; priv = bamf_view_get_instance_private (self); return _bamf_dbus_item_view_get_urgent (priv->proxy); } void _bamf_view_set_cached_name (BamfView *view, const char *name) { BamfViewPrivate *priv; g_return_if_fail (BAMF_IS_VIEW (view)); priv = bamf_view_get_instance_private (view); if (!name || g_strcmp0 (name, priv->cached_name) == 0) return; g_free (priv->cached_name); priv->cached_name = NULL; if (name && name[0] != '\0') { priv->cached_name = g_strdup (name); } } void _bamf_view_set_cached_icon (BamfView *view, const char *icon) { BamfViewPrivate *priv; g_return_if_fail (BAMF_IS_VIEW (view)); priv = bamf_view_get_instance_private (view); if (!icon || g_strcmp0 (icon, priv->cached_icon) == 0) return; g_free (priv->cached_icon); priv->cached_icon = NULL; if (icon && icon[0] != '\0') { priv->cached_icon = g_strdup (icon); } } gboolean bamf_view_is_sticky (BamfView *view) { BamfViewPrivate *priv; g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE); priv = bamf_view_get_instance_private (view); return priv->sticky; } void bamf_view_set_sticky (BamfView *view, gboolean sticky) { BamfViewPrivate *priv; g_return_if_fail (BAMF_IS_VIEW (view)); priv = bamf_view_get_instance_private (view); if (priv->sticky == sticky) return; priv->sticky = sticky; if (sticky) { g_object_ref_sink (view); } else { g_object_unref (view); } if (BAMF_VIEW_GET_CLASS (view)->set_sticky) return BAMF_VIEW_GET_CLASS (view)->set_sticky (view, sticky); } /** * bamf_view_get_icon: * @view: a #BamfView * * Gets the icon of a view. This icon is used to visually represent the view. */ gchar * bamf_view_get_icon (BamfView *self) { BamfViewPrivate *priv; g_return_val_if_fail (BAMF_IS_VIEW (self), NULL); priv = bamf_view_get_instance_private (self); if (BAMF_VIEW_GET_CLASS (self)->get_icon) return BAMF_VIEW_GET_CLASS (self)->get_icon (self); if (!_bamf_view_remote_ready (self)) return g_strdup (priv->cached_icon); return _bamf_dbus_item_view_dup_icon (priv->proxy); } /** * bamf_view_get_name: * @view: a #BamfView * * Gets the name of a view. This name is a short name best used to represent the view with text. */ gchar * bamf_view_get_name (BamfView *self) { BamfViewPrivate *priv; g_return_val_if_fail (BAMF_IS_VIEW (self), NULL); priv = bamf_view_get_instance_private (self); if (BAMF_VIEW_GET_CLASS (self)->get_name) return BAMF_VIEW_GET_CLASS (self)->get_name (self); if (!_bamf_view_remote_ready (self)) return g_strdup (priv->cached_name); return _bamf_dbus_item_view_dup_name (priv->proxy); } gboolean _bamf_view_remote_ready (BamfView *self) { BamfViewPrivate *priv; if (!BAMF_IS_VIEW (self)) return FALSE; priv = bamf_view_get_instance_private (self); if (G_IS_DBUS_PROXY (priv->proxy)) return !priv->is_closed; return FALSE; } /** * bamf_view_get_view_type: (virtual view_type) * @view: a #BamfView * * The view type of a window is a short string used to represent all views of the same class. These * descriptions should not be used to do casting as they are not considered stable. */ const gchar * bamf_view_get_view_type (BamfView *self) { BamfViewPrivate *priv; char *type = NULL; GError *error = NULL; g_return_val_if_fail (BAMF_IS_VIEW (self), NULL); priv = bamf_view_get_instance_private (self); if (BAMF_VIEW_GET_CLASS (self)->view_type) return BAMF_VIEW_GET_CLASS (self)->view_type (self); if (priv->type) return priv->type; if (!_bamf_view_remote_ready (self)) return NULL; if (!_bamf_dbus_item_view_call_view_type_sync (priv->proxy, &type, CANCELLABLE (self), &error)) { const gchar *path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (priv->proxy)); g_warning ("Failed to fetch view type at %s: %s", path, error ? error->message : ""); g_error_free (error); return NULL; } priv->type = type; return type; } BamfClickBehavior bamf_view_get_click_suggestion (BamfView *self) { g_return_val_if_fail (BAMF_IS_VIEW (self), BAMF_CLICK_BEHAVIOR_NONE); if (BAMF_VIEW_GET_CLASS (self)->click_behavior) return BAMF_VIEW_GET_CLASS (self)->click_behavior (self); return BAMF_CLICK_BEHAVIOR_NONE; } static void bamf_view_child_xid_changed (GObject *object, GParamSpec *pspec, gpointer user_data) { BamfView *self; self = (BamfView *)user_data; g_signal_emit (G_OBJECT (self), view_signals[CHILD_MOVED], 0, BAMF_VIEW (object)); g_signal_emit (G_OBJECT (self), view_signals[VISIBLE_CHANGED], 0); } static void bamf_view_on_child_added (BamfDBusItemView *proxy, const char *path, BamfView *self) { BamfView *view; BamfViewPrivate *priv; view = _bamf_factory_view_for_path (_bamf_factory_get_default (), path); priv = bamf_view_get_instance_private (self); g_return_if_fail (BAMF_IS_VIEW (view)); if (BAMF_IS_TAB (view)) { g_signal_connect (view, "notify::xid", G_CALLBACK (bamf_view_child_xid_changed), self); } if (!g_list_find (priv->cached_children, view)) { g_object_ref (view); priv->cached_children = g_list_prepend (priv->cached_children, view); } g_signal_emit (G_OBJECT (self), view_signals[CHILD_ADDED], 0, view); } static void bamf_view_on_child_removed (BamfDBusItemView *proxy, char *path, BamfView *self) { BamfView *view; BamfViewPrivate *priv; gboolean was_cached = FALSE; view = _bamf_factory_view_for_path (_bamf_factory_get_default (), path); priv = bamf_view_get_instance_private (self); g_return_if_fail (BAMF_IS_VIEW (view)); if (BAMF_IS_TAB (view)) { g_signal_handlers_disconnect_by_func (view, bamf_view_child_xid_changed, self); } if (priv->cached_children) { GList *l = g_list_find (priv->cached_children, view); if (l) { priv->cached_children = g_list_delete_link (priv->cached_children, l); was_cached = TRUE; } } g_signal_emit (G_OBJECT (self), view_signals[CHILD_REMOVED], 0, view); if (was_cached) g_object_unref (view); } static void bamf_view_on_name_owner_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self) { BamfViewPrivate *priv = priv = bamf_view_get_instance_private (self); /* This is called when the bamfdaemon is killed / started */ gchar *name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (proxy)); if (!name_owner) { if (priv->cached_children) { g_list_free_full (priv->cached_children, g_object_unref); priv->reload_children = TRUE; priv->cached_children = NULL; } if (priv->cached_name) { const char *cached_name = priv->cached_name; g_signal_emit (G_OBJECT (self), view_signals[NAME_CHANGED], 0, NULL, cached_name); } if (priv->cached_icon) { const char *cached_icon = priv->cached_icon; g_signal_emit (G_OBJECT (self), view_signals[ICON_CHANGED], 0, cached_icon); } _bamf_view_set_closed (self, TRUE); g_signal_emit (G_OBJECT (self), view_signals[CLOSED], 0); } g_free (name_owner); } static void bamf_view_on_active_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self) { gboolean active = _bamf_dbus_item_view_get_active (proxy); g_signal_emit (G_OBJECT (self), view_signals[ACTIVE_CHANGED], 0, active); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ACTIVE]); } static void bamf_view_on_name_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self) { BamfViewPrivate *priv = bamf_view_get_instance_private (self); const char *new_name = _bamf_dbus_item_view_get_name (proxy); const char *old_name = priv->cached_name; g_signal_emit (self, view_signals[NAME_CHANGED], 0, old_name, new_name); _bamf_view_set_cached_name (self, new_name); } static void bamf_view_on_icon_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self) { const char *icon = _bamf_dbus_item_view_get_icon (proxy); g_signal_emit (self, view_signals[ICON_CHANGED], 0, icon); _bamf_view_set_cached_icon (self, icon); } static void bamf_view_on_starting_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self) { gboolean starting = _bamf_dbus_item_view_get_starting (proxy); g_signal_emit (G_OBJECT (self), view_signals[STARTING_CHANGED], 0, starting); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_STARTING]); } static void bamf_view_on_running_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self) { gboolean running = _bamf_dbus_item_view_get_running (proxy); g_signal_emit (G_OBJECT (self), view_signals[RUNNING_CHANGED], 0, running); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RUNNING]); } static void bamf_view_on_urgent_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self) { gboolean urgent = _bamf_dbus_item_view_get_urgent (proxy); g_signal_emit (G_OBJECT (self), view_signals[URGENT_CHANGED], 0, urgent); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_URGENT]); } static void bamf_view_on_user_visible_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self) { gboolean user_visible = _bamf_dbus_item_view_get_user_visible (proxy); g_signal_emit (G_OBJECT (self), view_signals[VISIBLE_CHANGED], 0, user_visible); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_USER_VISIBLE]); } GCancellable * _bamf_view_get_cancellable (BamfView *view) { BamfViewPrivate *priv; g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); priv = bamf_view_get_instance_private (view); return priv->cancellable; } void _bamf_view_set_closed (BamfView *self, gboolean closed) { BamfViewPrivate *priv; g_return_if_fail (BAMF_IS_VIEW (self)); priv = bamf_view_get_instance_private (self); if (priv->is_closed != closed) { priv->is_closed = closed; if (closed) { g_cancellable_cancel (priv->cancellable); g_list_free_full (priv->cached_children, g_object_unref); priv->cached_children = NULL; } else { g_cancellable_reset (priv->cancellable); } } } static void bamf_view_on_closed (BamfDBusItemView *proxy, BamfView *self) { _bamf_view_set_closed (self, TRUE); g_signal_emit (G_OBJECT (self), view_signals[CLOSED], 0); } static void bamf_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { switch (property_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void bamf_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { BamfView *self; self = BAMF_VIEW (object); switch (property_id) { case PROP_PATH: g_value_set_string (value, bamf_view_is_closed (self) ? NULL : _bamf_view_get_path (self)); break; case PROP_ACTIVE: g_value_set_boolean (value, bamf_view_is_active (self)); break; case PROP_STARTING: g_value_set_boolean (value, bamf_view_is_starting (self)); break; case PROP_RUNNING: g_value_set_boolean (value, bamf_view_is_running (self)); break; case PROP_URGENT: g_value_set_boolean (value, bamf_view_is_urgent (self)); break; case PROP_USER_VISIBLE: g_value_set_boolean (value, bamf_view_is_user_visible (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } static void bamf_view_unset_proxy (BamfView *self) { BamfViewPrivate *priv; g_return_if_fail (BAMF_IS_VIEW (self)); priv = bamf_view_get_instance_private (self); if (!priv->proxy) return; g_signal_handlers_disconnect_by_data (priv->proxy, self); g_object_unref (priv->proxy); priv->proxy = NULL; } static void bamf_view_dispose (GObject *object) { BamfView *view; BamfViewPrivate *priv; view = BAMF_VIEW (object); priv = bamf_view_get_instance_private (view); if (priv->cancellable) { g_cancellable_cancel (priv->cancellable); g_object_unref (priv->cancellable); priv->cancellable = NULL; } if (priv->type) { g_free (priv->type); priv->type = NULL; } if (priv->cached_icon) { g_free (priv->cached_icon); priv->cached_icon = NULL; } if (priv->cached_name) { g_free (priv->cached_name); priv->cached_name = NULL; } if (priv->cached_children) { g_list_free_full (priv->cached_children, g_object_unref); priv->cached_children = NULL; } bamf_view_unset_proxy (view); G_OBJECT_CLASS (bamf_view_parent_class)->dispose (object); } const char * _bamf_view_get_path (BamfView *view) { BamfViewPrivate *priv; g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); priv = bamf_view_get_instance_private (view); if (G_IS_DBUS_PROXY (priv->proxy)) return g_dbus_proxy_get_object_path (G_DBUS_PROXY (priv->proxy)); return NULL; } void _bamf_view_reset_flags (BamfView *view) { BamfViewPrivate *priv; g_return_if_fail (BAMF_IS_VIEW (view)); priv = bamf_view_get_instance_private (view); /* Notifying proxy properties makes the view to emit proper signals */ g_object_notify (G_OBJECT (priv->proxy), "user-visible"); g_object_notify (G_OBJECT (priv->proxy), "active"); g_object_notify (G_OBJECT (priv->proxy), "starting"); g_object_notify (G_OBJECT (priv->proxy), "running"); g_object_notify (G_OBJECT (priv->proxy), "urgent"); g_object_notify (G_OBJECT (priv->proxy), "name"); } void _bamf_view_set_path (BamfView *view, const char *path) { BamfViewPrivate *priv; GError *error = NULL; g_return_if_fail (BAMF_IS_VIEW (view)); g_return_if_fail (path); _bamf_view_set_closed (view, FALSE); if (g_strcmp0 (_bamf_view_get_path (view), path) == 0) { // The proxy path has not been changed, no need to unset and re-set it again _bamf_view_reset_flags (view); return; } bamf_view_unset_proxy (view); priv = bamf_view_get_instance_private (view); priv->reload_children = TRUE; priv->proxy = _bamf_dbus_item_view_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, BAMF_DBUS_SERVICE_NAME, path, CANCELLABLE (view), &error); if (!G_IS_DBUS_PROXY (priv->proxy)) { g_critical ("Unable to get %s view: %s", BAMF_DBUS_SERVICE_NAME, error ? error ? error->message : "" : ""); g_error_free (error); return; } g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (priv->proxy), BAMF_DBUS_DEFAULT_TIMEOUT); g_object_notify_by_pspec (G_OBJECT (view), properties[PROP_PATH]); g_signal_connect (priv->proxy, "notify::g-name-owner", G_CALLBACK (bamf_view_on_name_owner_changed), view); g_signal_connect (priv->proxy, "notify::active", G_CALLBACK (bamf_view_on_active_changed), view); g_signal_connect (priv->proxy, "notify::starting", G_CALLBACK (bamf_view_on_starting_changed), view); g_signal_connect (priv->proxy, "notify::running", G_CALLBACK (bamf_view_on_running_changed), view); g_signal_connect (priv->proxy, "notify::urgent", G_CALLBACK (bamf_view_on_urgent_changed), view); g_signal_connect (priv->proxy, "notify::user-visible", G_CALLBACK (bamf_view_on_user_visible_changed), view); g_signal_connect (priv->proxy, "notify::name", G_CALLBACK (bamf_view_on_name_changed), view); g_signal_connect (priv->proxy, "notify::icon", G_CALLBACK (bamf_view_on_icon_changed), view); g_signal_connect (priv->proxy, "child-added", G_CALLBACK (bamf_view_on_child_added), view); g_signal_connect (priv->proxy, "child-removed", G_CALLBACK (bamf_view_on_child_removed), view); g_signal_connect (priv->proxy, "closed", G_CALLBACK (bamf_view_on_closed), view); _bamf_view_reset_flags (view); if (BAMF_VIEW_GET_CLASS (view)->set_path) BAMF_VIEW_GET_CLASS (view)->set_path (view, path); } static void bamf_view_class_init (BamfViewClass *klass) { GObjectClass *obj_class = G_OBJECT_CLASS (klass); obj_class->dispose = bamf_view_dispose; obj_class->get_property = bamf_view_get_property; obj_class->set_property = bamf_view_set_property; properties[PROP_PATH] = g_param_spec_string ("path", "path", "path", NULL, G_PARAM_READABLE); g_object_class_install_property (obj_class, PROP_PATH, properties[PROP_PATH]); properties[PROP_ACTIVE] = g_param_spec_boolean ("active", "active", "active", FALSE, G_PARAM_READABLE); g_object_class_install_property (obj_class, PROP_ACTIVE, properties[PROP_ACTIVE]); properties[PROP_URGENT] = g_param_spec_boolean ("urgent", "urgent", "urgent", FALSE, G_PARAM_READABLE); g_object_class_install_property (obj_class, PROP_URGENT, properties[PROP_URGENT]); properties[PROP_STARTING] = g_param_spec_boolean ("starting", "starting", "starting", FALSE, G_PARAM_READABLE); g_object_class_install_property (obj_class, PROP_STARTING, properties[PROP_STARTING]); properties[PROP_RUNNING] = g_param_spec_boolean ("running", "running", "running", FALSE, G_PARAM_READABLE); g_object_class_install_property (obj_class, PROP_RUNNING, properties[PROP_RUNNING]); properties[PROP_USER_VISIBLE] = g_param_spec_boolean ("user-visible", "user-visible", "user-visible", FALSE, G_PARAM_READABLE); g_object_class_install_property (obj_class, PROP_USER_VISIBLE, properties[PROP_USER_VISIBLE]); view_signals [ACTIVE_CHANGED] = g_signal_new (BAMF_VIEW_SIGNAL_ACTIVE_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfViewClass, active_changed), NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); view_signals [CLOSED] = g_signal_new (BAMF_VIEW_SIGNAL_CLOSED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (BamfViewClass, closed), NULL, NULL, NULL, G_TYPE_NONE, 0); view_signals [CHILD_ADDED] = g_signal_new (BAMF_VIEW_SIGNAL_CHILD_ADDED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfViewClass, child_added), NULL, NULL, NULL, G_TYPE_NONE, 1, BAMF_TYPE_VIEW); view_signals [CHILD_REMOVED] = g_signal_new (BAMF_VIEW_SIGNAL_CHILD_REMOVED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfViewClass, child_removed), NULL, NULL, NULL, G_TYPE_NONE, 1, BAMF_TYPE_VIEW); view_signals [CHILD_MOVED] = g_signal_new (BAMF_VIEW_SIGNAL_CHILD_MOVED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfViewClass, child_moved), NULL, NULL, NULL, G_TYPE_NONE, 1, BAMF_TYPE_VIEW); view_signals [STARTING_CHANGED] = g_signal_new (BAMF_VIEW_SIGNAL_STARTING_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfViewClass, starting_changed), NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); view_signals [RUNNING_CHANGED] = g_signal_new (BAMF_VIEW_SIGNAL_RUNNING_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfViewClass, running_changed), NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); view_signals [URGENT_CHANGED] = g_signal_new (BAMF_VIEW_SIGNAL_URGENT_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfViewClass, urgent_changed), NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); view_signals [VISIBLE_CHANGED] = g_signal_new (BAMF_VIEW_SIGNAL_USER_VISIBLE_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfViewClass, user_visible_changed), NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); view_signals [NAME_CHANGED] = g_signal_new (BAMF_VIEW_SIGNAL_NAME_CHANGED, G_OBJECT_CLASS_TYPE (klass), 0, G_STRUCT_OFFSET (BamfViewClass, name_changed), NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); view_signals [ICON_CHANGED] = g_signal_new (BAMF_VIEW_SIGNAL_ICON_CHANGED, G_OBJECT_CLASS_TYPE (klass), 0, G_STRUCT_OFFSET (BamfViewClass, icon_changed), NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING); } static void bamf_view_init (BamfView *self) { BamfViewPrivate *priv; priv = bamf_view_get_instance_private (self); priv->cancellable = g_cancellable_new (); priv->is_closed = TRUE; priv->reload_children = TRUE; } ./lib/libbamf/Makefile.am0000644000004100000410000000551214203512426015443 0ustar www-datawww-data-include $(INTROSPECTION_MAKEFILE) LIBBAMF_PRIVATE_LIB = $(top_builddir)/lib/libbamf-private/libbamf-private.la libbamf_sources = \ bamf-application.c \ bamf-control.c \ bamf-matcher.c \ bamf-view.c \ bamf-window.c \ bamf-factory.c \ bamf-tab.c \ $(NULL) libbamf_headers = \ bamf-application.h \ bamf-control.h \ bamf-matcher.h \ bamf-view.h \ bamf-window.h \ bamf-tab.h \ libbamf.h \ $(NULL) libbamf_private_headers = \ bamf-factory.h \ bamf-application-private.h \ bamf-view-private.h \ $(NULL) libbamf_la_SOURCES = \ $(libbamf_built_sources) \ $(libbamf_private_headers) \ $(libbamf_headers) \ $(libbamf_sources) \ $(NULL) libbamf_la_LIBADD = \ $(LIBBAMF_PRIVATE_LIB) \ $(LIBWSBIND_LIBS) \ $(GLIB_LIBS) \ $(COVERAGE_LIBS) \ $(NULL) libbamf_la_CFLAGS = \ -Wall -std=c99 \ -fPIC \ -DDATADIR=\""$(datadir)"\" \ -I$(srcdir) \ -I$(top_srcdir)/lib \ -I$(top_builddir)/lib \ $(COVERAGE_CFLAGS) \ $(LIBWSBIND_CFLAGS) \ $(GLIB_CFLAGS) \ $(NULL) libbamf_la_LDFLAGS = \ -shared \ -export-symbols-regex "^bamf_" \ -version-info $(LIBBAMF_SONAME) \ $(COVERAGE_LDFLAGS) \ $(NULL) lib_LTLIBRARIES = libbamf3.la libbamf3_la_SOURCES = $(libbamf_la_SOURCES) libbamf3_la_LIBADD = $(libbamf_la_LIBADD) libbamf3_la_CFLAGS = $(libbamf_la_CFLAGS) libbamf3_la_LDFLAGS = $(libbamf_la_LDFLAGS) libbamf_includedir=$(includedir)/libbamf$(LIBBAMF_VER)/libbamf libbamf_include_HEADERS = \ $(libbamf_headers) libbamf_pcdir = $(libdir)/pkgconfig libbamf_pc_DATA = \ libbamf$(LIBBAMF_VER).pc BUILT_SOURCES = \ $(libbamf_gdbus_files) \ $(NULL) DISTCLEANFILES = \ $(libbamf_built_sources) \ $(NULL) CLEANFILES = \ $(libbamf_built_sources) \ $(NULL) ######################### # GObject Introsepction ######################### if HAVE_INTROSPECTION INTROSPECTION_GIRS = Bamf-3.gir INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) introspection_sources = \ $(libbamf_headers) \ $(libbamf_sources) \ $(NULL) Bamf-3.gir: libbamf$(LIBBAMF_VER).la Bamf_3_gir_INCLUDES = GObject-2.0 GLib-2.0 Bamf_3_gir_SCANNERFLAGS = --warn-all --c-include='libbamf/libbamf.h' Bamf_3_gir_CFLAGS = \ $(DBUS_CFLAGS) \ -I$(top_srcdir)/lib \ -I$(top_builddir)/lib \ $(NULL) Bamf_3_gir_LIBS = libbamf$(LIBBAMF_VER).la Bamf_3_gir_FILES = $(introspection_sources) Bamf_3_gir_EXPORT_PACKAGES = libbamf$(LIBBAMF_VER) girdir = $(INTROSPECTION_GIRDIR) gir_DATA = $(INTROSPECTION_GIRS) typelibdir = $(INTROSPECTION_TYPELIBDIR) typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) CLEANFILES += $(gir_DATA) $(typelib_DATA) endif ######################### # VAPI Files ######################### if HAVE_INTROSPECTION vapidir = $(datadir)/vala/vapi vapi_DATA = libbamf$(LIBBAMF_VER).vapi $(vapi_DATA): $(INTROSPECTION_GIRS) $(AM_V_GEN)$(VALA_API_GEN) --library=$(@:.vapi=) $< CLEANFILES += $(vapi_DATA) endif ./lib/libbamf/bamf-window.c0000644000004100000410000003042414203512426015765 0ustar www-datawww-data/* * Copyright 2010-2012 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of either or both of the following licenses: * * 1) the GNU Lesser General Public License version 3, as published by the * Free Software Foundation; and/or * 2) the GNU Lesser General Public License version 2.1, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR * PURPOSE. See the applicable version of the GNU Lesser General Public * License for more details. * * You should have received a copy of both the GNU Lesser General Public * License version 3 and version 2.1 along with this program. If not, see * * * Authored by: Jason Smith * Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ /** * SECTION:bamf-window * @short_description: The base class for all windows * * #BamfWindow is the base class that all windows need to derive from. */ #if HAVE_CONFIG_H #include #endif #include #include "bamf-view-private.h" #include "bamf-window.h" #include "bamf-factory.h" typedef struct _BamfWindowPrivate { BamfDBusItemWindow *proxy; guint32 xid; guint32 pid; time_t last_active; gint monitor; BamfWindowType type; BamfWindowMaximizationType maximized; } BamfWindowPrivate; G_DEFINE_TYPE_WITH_PRIVATE (BamfWindow, bamf_window, BAMF_TYPE_VIEW); enum { MONITOR_CHANGED, MAXIMIZED_CHANGED, LAST_SIGNAL, }; static guint window_signals[LAST_SIGNAL] = { 0 }; time_t bamf_window_last_active (BamfWindow *self) { BamfWindowPrivate *priv; g_return_val_if_fail (BAMF_IS_WINDOW (self), 0); if (BAMF_WINDOW_GET_CLASS (self)->last_active) return BAMF_WINDOW_GET_CLASS (self)->last_active (self); priv = bamf_window_get_instance_private (self); return priv->last_active; } /** * bamf_window_get_transient: * @self: a #BamfWindow * * Returns: (transfer none) (allow-none): A transient for this #BamfWindow. */ BamfWindow * bamf_window_get_transient (BamfWindow *self) { BamfWindowPrivate *priv; BamfView *transient; char *path = NULL; GError *error = NULL; g_return_val_if_fail (BAMF_IS_WINDOW (self), FALSE); if (BAMF_WINDOW_GET_CLASS (self)->get_transient) return BAMF_WINDOW_GET_CLASS (self)->get_transient (self); priv = bamf_window_get_instance_private (self); if (!_bamf_view_remote_ready (BAMF_VIEW (self))) return NULL; if (!_bamf_dbus_item_window_call_transient_sync (priv->proxy, &path, CANCELLABLE (self), &error)) { g_warning ("Failed to fetch path: %s", error ? error->message : ""); g_error_free (error); return NULL; } if (!path) return NULL; if (path[0] == '\0') { g_free (path); return NULL; } BamfFactory *factory = _bamf_factory_get_default (); transient = _bamf_factory_view_for_path_type (factory, path, BAMF_FACTORY_WINDOW); g_free (path); if (!BAMF_IS_WINDOW (transient)) return NULL; return BAMF_WINDOW (transient); } BamfWindowType bamf_window_get_window_type (BamfWindow *self) { BamfWindowPrivate *priv; GError *error = NULL; g_return_val_if_fail (BAMF_IS_WINDOW (self), FALSE); if (BAMF_WINDOW_GET_CLASS (self)->get_window_type) return BAMF_WINDOW_GET_CLASS (self)->get_window_type (self); priv = bamf_window_get_instance_private (self); if (priv->type != BAMF_WINDOW_UNKNOWN) return priv->type; if (!_bamf_view_remote_ready (BAMF_VIEW (self))) return priv->type; if (!_bamf_dbus_item_window_call_window_type_sync (priv->proxy, &priv->type, CANCELLABLE (self), &error)) { priv->type = BAMF_WINDOW_UNKNOWN; g_warning ("Failed to fetch type: %s", error ? error->message : ""); g_error_free (error); } return priv->type; } guint32 bamf_window_get_pid (BamfWindow *self) { BamfWindowPrivate *priv; GError *error = NULL; g_return_val_if_fail (BAMF_IS_WINDOW (self), FALSE); if (BAMF_WINDOW_GET_CLASS (self)->get_pid) return BAMF_WINDOW_GET_CLASS (self)->get_pid (self); priv = bamf_window_get_instance_private (self); if (priv->pid != 0) return priv->pid; if (!_bamf_view_remote_ready (BAMF_VIEW (self))) return priv->pid; if (!_bamf_dbus_item_window_call_get_pid_sync (priv->proxy, &priv->pid, CANCELLABLE (self), &error)) { priv->pid = 0; g_warning ("Failed to fetch pid: %s", error ? error->message : ""); g_error_free (error); } return priv->pid; } guint32 bamf_window_get_xid (BamfWindow *self) { BamfWindowPrivate *priv; GError *error = NULL; g_return_val_if_fail (BAMF_IS_WINDOW (self), FALSE); if (BAMF_WINDOW_GET_CLASS (self)->get_xid) return BAMF_WINDOW_GET_CLASS (self)->get_xid (self); priv = bamf_window_get_instance_private (self); if (priv->xid != 0) return priv->xid; if (!_bamf_view_remote_ready (BAMF_VIEW (self))) return priv->xid; if (!_bamf_dbus_item_window_call_get_xid_sync (priv->proxy, &priv->xid, CANCELLABLE (self), &error)) { priv->xid = 0; g_warning ("Failed to fetch xid: %s", error ? error->message : ""); g_error_free (error); } return priv->xid; } gchar * bamf_window_get_utf8_prop (BamfWindow *self, const char* xprop) { BamfWindowPrivate *priv; char *result = NULL; GError *error = NULL; g_return_val_if_fail (BAMF_IS_WINDOW (self), NULL); g_return_val_if_fail (xprop, NULL); if (BAMF_WINDOW_GET_CLASS (self)->get_utf8_prop) return BAMF_WINDOW_GET_CLASS (self)->get_utf8_prop (self, xprop); priv = bamf_window_get_instance_private (self); if (!_bamf_view_remote_ready (BAMF_VIEW (self))) return NULL; if (!_bamf_dbus_item_window_call_xprop_sync (priv->proxy, xprop, &result, CANCELLABLE (self), &error)) { g_warning ("Failed to fetch property `%s': %s", xprop, error ? error->message : ""); g_error_free (error); return NULL; } if (result && result[0] == '\0') { g_free (result); result = NULL; } return result; } gint bamf_window_get_monitor (BamfWindow *self) { BamfWindowPrivate *priv; gint monitor = -2; GError *error = NULL; g_return_val_if_fail (BAMF_IS_WINDOW (self), -1); if (BAMF_WINDOW_GET_CLASS (self)->get_monitor) return BAMF_WINDOW_GET_CLASS (self)->get_monitor (self); priv = bamf_window_get_instance_private (self); if (priv->monitor != -2 || !_bamf_view_remote_ready (BAMF_VIEW (self))) { return priv->monitor; } if (!_bamf_dbus_item_window_call_monitor_sync (priv->proxy, &monitor, CANCELLABLE (self), &error)) { g_warning ("Failed to fetch monitor: %s", error ? error->message : ""); g_error_free (error); monitor = -1; } return monitor; } BamfWindowMaximizationType bamf_window_maximized (BamfWindow *self) { BamfWindowPrivate *priv; GError *error = NULL; g_return_val_if_fail (BAMF_IS_WINDOW (self), -1); if (BAMF_WINDOW_GET_CLASS (self)->maximized) return BAMF_WINDOW_GET_CLASS (self)->maximized (self); priv = bamf_window_get_instance_private (self); if (priv->maximized != -1 || !_bamf_view_remote_ready (BAMF_VIEW (self))) { return priv->maximized; } if (!_bamf_dbus_item_window_call_maximized_sync (priv->proxy, (gint*) &priv->maximized, CANCELLABLE (self), &error)) { priv->maximized = -1; g_warning ("Failed to fetch maximized state: %s", error->message); g_error_free (error); } return priv->maximized; } static void bamf_window_active_changed (BamfView *view, gboolean active) { g_return_if_fail (BAMF_IS_WINDOW (view)); if (active) { BamfWindowPrivate *priv; priv = bamf_window_get_instance_private (BAMF_WINDOW (view)); priv->last_active = time (NULL); } } static void bamf_window_on_monitor_changed (BamfDBusItemWindow *proxy, gint old, gint new, BamfWindow *self) { BamfWindowPrivate *priv = bamf_window_get_instance_private (self); priv->monitor = new; g_signal_emit (G_OBJECT (self), window_signals[MONITOR_CHANGED], 0, old, new); } static void bamf_window_on_maximized_changed (BamfDBusItemWindow *proxy, gint old, gint new, BamfWindow *self) { BamfWindowPrivate *priv = bamf_window_get_instance_private (self); priv->maximized = new; g_signal_emit (G_OBJECT (self), window_signals[MAXIMIZED_CHANGED], 0, old, new); } static void bamf_window_unset_proxy (BamfWindow *self) { BamfWindowPrivate *priv; g_return_if_fail (BAMF_IS_WINDOW (self)); priv = bamf_window_get_instance_private (self); if (!G_IS_DBUS_PROXY (priv->proxy)) return; g_signal_handlers_disconnect_by_data (priv->proxy, self); g_object_unref (priv->proxy); priv->proxy = NULL; } static void bamf_window_set_path (BamfView *view, const char *path) { BamfWindow *self; BamfWindowPrivate *priv; GError *error = NULL; self = BAMF_WINDOW (view); priv = bamf_window_get_instance_private (self); bamf_window_unset_proxy (self); priv->proxy = _bamf_dbus_item_window_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, BAMF_DBUS_SERVICE_NAME, path, CANCELLABLE (self), &error); if (!G_IS_DBUS_PROXY (priv->proxy)) { g_error ("Unable to get %s window: %s", BAMF_DBUS_SERVICE_NAME, error ? error->message : ""); g_error_free (error); return; } g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (priv->proxy), BAMF_DBUS_DEFAULT_TIMEOUT); priv->xid = bamf_window_get_xid (self); priv->type = bamf_window_get_window_type (self); priv->monitor = bamf_window_get_monitor (self); priv->maximized = bamf_window_maximized (self); g_signal_connect (priv->proxy, "monitor-changed", G_CALLBACK (bamf_window_on_monitor_changed), self); g_signal_connect (priv->proxy, "maximized-changed", G_CALLBACK (bamf_window_on_maximized_changed), self); } static void bamf_window_dispose (GObject *object) { BamfWindow *self = BAMF_WINDOW (object); bamf_window_unset_proxy (self); if (G_OBJECT_CLASS (bamf_window_parent_class)->dispose) G_OBJECT_CLASS (bamf_window_parent_class)->dispose (object); } static void bamf_window_class_init (BamfWindowClass *klass) { GObjectClass *obj_class = G_OBJECT_CLASS (klass); BamfViewClass *view_class = BAMF_VIEW_CLASS (klass); obj_class->dispose = bamf_window_dispose; view_class->active_changed = bamf_window_active_changed; view_class->set_path = bamf_window_set_path; window_signals[MONITOR_CHANGED] = g_signal_new (BAMF_WINDOW_SIGNAL_MONITOR_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfWindowClass, monitor_changed), NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); window_signals[MAXIMIZED_CHANGED] = g_signal_new (BAMF_WINDOW_SIGNAL_MAXIMIZED_CHANGED, G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (BamfWindowClass, maximized_changed), NULL, NULL, NULL, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); } static void bamf_window_init (BamfWindow *self) { BamfWindowPrivate *priv; priv = bamf_window_get_instance_private (self); priv->type = BAMF_WINDOW_UNKNOWN; priv->monitor = -2; priv->maximized = -1; } BamfWindow * bamf_window_new (const char * path) { BamfWindow *self = g_object_new (BAMF_TYPE_WINDOW, NULL); _bamf_view_set_path (BAMF_VIEW (self), path); return self; } ./Makefile.am.coverage0000644000004100000410000000257514203512426015101 0ustar www-datawww-data # Coverage targets .PHONY: clean-gcno clean-gcda \ coverage-html generate-coverage-html clean-coverage-html \ coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr clean-local: clean-gcno clean-coverage-html clean-coverage-gcovr clean-gcno: @echo Removing old coverage instrumentation -find -name '*.gcno' -print | xargs -r rm clean-gcda: @echo Removing old coverage results -find -name '*.gcda' -print | xargs -r rm if HAVE_GCOV coverage-html: -$(MAKE) $(AM_MAKEFLAGS) -k check $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html generate-coverage-html: @echo Collecting coverage data $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info clean-coverage-html: clean-gcda -$(LCOV) --directory $(top_builddir) -z -rm -rf coverage.info coveragereport if HAVE_GCOVR coverage-gcovr: -$(MAKE) $(AM_MAKEFLAGS) -k check $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr coverage-xml: coverage-gcovr generate-coverage-gcovr: @echo Generating coverage GCOVR report $(GCOVR) --xml -r $(top_builddir) -e "tests.*" -o $(top_builddir)/coverage.xml endif # HAVE_GCOVR endif # HAVE_GCOV clean-coverage-gcovr: clean-gcda -rm -f $(top_builddir)/coverage.xml clean-coverage-xml: clean-coverage-gcovr ./tests/0000755000004100000410000000000014203512426012404 5ustar www-datawww-data./tests/gtester2xunit.py0000755000004100000410000000357114203512426015616 0ustar www-datawww-data#! /usr/bin/python3 from argparse import ArgumentParser from lxml import etree import sys import os XSL_TRANSFORM='/usr/share/gtester2xunit/gtester.xsl' def transform_file(input_filename, output_filename, xsl_file): gtester = etree.parse(xsl_file) transform = etree.XSLT(gtester) doc = etree.parse(input_filename) result = transform(doc) result.write(output_filename) def get_output_filename(input_filename): filename, extension = os.path.splitext(input_filename) return '{filename}-xunit{extension}'.format(filename=filename, extension=extension) def main(): parser = ArgumentParser( description="Simple utility that converts xml output of " + "gtester to xunit output for jenkins") parser.add_argument('-o', '--output', help="Write output to specified file instead of default") parser.add_argument('-x', '--xsl', help="xsl file that should be used for the transformation") parser.add_argument('-i', '--in-place', help="Write the ouput to the original file (i.e. replace " + "the original xml)", action='store_true', default=False) parser.add_argument('files', metavar='FILE', type=str, nargs='+', help="file(s) to transform to xunit format") args = vars(parser.parse_args()) for input_filename in args['files']: if not args['output']: if args['in_place']: output_filename = input_filename else: output_filename = get_output_filename(input_filename) else: output_filename = args['output'] if not args['xsl']: xsl = XSL_TRANSFORM else: xsl = args['xsl'] transform_file(input_filename, output_filename, xsl) sys.exit(main()) # vim: set syntex=python: ./tests/bamfdaemon/0000755000004100000410000000000014203512426014475 5ustar www-datawww-data./tests/bamfdaemon/test-bamf.c0000644000004100000410000000566514203512426016537 0ustar www-datawww-data/* * Copyright (C) 2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include #include #include #include #include #include #include #include #include void test_application_create_suite (GDBusConnection *connection); void test_matcher_create_suite (GDBusConnection *connection); void test_view_create_suite (GDBusConnection *connection); void test_window_create_suite (void); static int result = 1; static gboolean not_fatal_log_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) { // Don't crash if used return FALSE; } void ignore_fatal_errors (void) { g_test_log_set_fatal_handler (not_fatal_log_handler, NULL); } static void on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer data) { GMainLoop *loop = data; GtkIconTheme *icon_theme; g_setenv ("BAMF_TEST_MODE", "TRUE", TRUE); g_setenv ("PATH", TESTDIR"/data/bin", TRUE); icon_theme = gtk_icon_theme_get_default (); gtk_icon_theme_prepend_search_path (icon_theme, TESTDIR"/data/icons"); test_matcher_create_suite (connection); test_view_create_suite (connection); test_window_create_suite (); test_application_create_suite (connection); result = g_test_run (); g_main_loop_quit (loop); } static void on_name_lost (GDBusConnection *connection, const gchar *name, gpointer data) { GMainLoop *loop = data; g_main_loop_quit (loop); } gint main (gint argc, gchar *argv[]) { GMainLoop *loop; GFile *tmp_dir; gchar *tmp_path; tmp_path = g_dir_make_tmp (".bamfhomedataXXXXXX", NULL); tmp_dir = g_file_new_for_path (tmp_path); g_file_make_directory (tmp_dir, NULL, NULL); g_setenv ("XDG_DATA_HOME", tmp_path, TRUE); g_free (tmp_path); gtk_init (&argc, &argv); g_test_init (&argc, &argv, NULL); glibtop_init (); loop = g_main_loop_new (NULL, FALSE); g_bus_own_name (G_BUS_TYPE_SESSION, BAMF_DBUS_SERVICE_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, NULL, on_name_lost, loop, NULL); g_main_loop_run (loop); g_file_delete (tmp_dir, NULL, NULL); g_object_unref (tmp_dir); return result; } ./tests/bamfdaemon/test-view.c0000644000004100000410000006677114203512426016611 0ustar www-datawww-data/* * Copyright (C) 2009-2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by Neil Jagdish Patel * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include #include #include "bamf-view.h" static GDBusConnection *gdbus_connection = NULL; static void test_allocation (void) { BamfView *view; view = g_object_new (BAMF_TYPE_VIEW, NULL); g_assert (BAMF_IS_VIEW (view)); g_object_unref (G_OBJECT (view)); } #define test_string_property(prop) test_##prop #define declare_test_string_property(prop) \ static void \ test_string_property (prop) (void) \ { \ BamfView *view; \ \ view = g_object_new (BAMF_TYPE_VIEW, NULL); \ g_assert (!bamf_view_get_##prop (view)); \ \ const gchar *new_##prop = "Some" #prop; \ bamf_view_set_##prop (view, new_##prop); \ g_assert_cmpstr (bamf_view_get_##prop (view), ==, new_##prop); \ \ new_##prop = "Another" #prop; \ bamf_view_set_##prop (view, new_##prop); \ g_assert_cmpstr (bamf_view_get_##prop (view), ==, new_##prop); \ \ g_object_unref (view); \ } declare_test_string_property (name); declare_test_string_property (icon); #define test_string_property_exported(prop) test_##prop##_exported #define declare_test_string_property_exported(prop) \ static void \ test_string_property_exported (prop) (void) \ { \ BamfView *view; \ \ view = g_object_new (BAMF_TYPE_VIEW, NULL); \ g_assert (!bamf_view_get_##prop (view)); \ \ const gchar *new_##prop = "Some" #prop; \ bamf_view_set_##prop (view, new_##prop); \ bamf_view_export_on_bus (view, gdbus_connection); \ g_assert_cmpstr (bamf_view_get_##prop (view), ==, new_##prop); \ \ new_##prop = "Another" #prop; \ bamf_view_set_##prop (view, new_##prop); \ g_assert_cmpstr (bamf_view_get_##prop (view), ==, new_##prop); \ \ g_object_unref (view); \ } declare_test_string_property_exported (name); declare_test_string_property_exported (icon); #define test_boolean_property(prop) test_##prop #define declare_test_boolean_property(prop) \ static void \ test_boolean_property (prop) (void) \ { \ BamfView *view; \ \ view = g_object_new (BAMF_TYPE_VIEW, NULL); \ g_assert (!bamf_view_is_##prop (view)); \ \ bamf_view_set_##prop (view, TRUE); \ g_assert (bamf_view_is_##prop (view)); \ \ bamf_view_set_##prop (view, FALSE); \ g_assert (!bamf_view_is_##prop (view)); \ \ g_object_unref (view); \ } declare_test_boolean_property (active); declare_test_boolean_property (running); declare_test_boolean_property (urgent); declare_test_boolean_property (user_visible); #define test_boolean_property_exported(prop) test_##prop##_exported #define declare_test_boolean_property_exported(prop) \ static void \ test_boolean_property_exported(prop) (void) \ { \ BamfView *view; \ \ view = g_object_new (BAMF_TYPE_VIEW, NULL); \ bamf_view_set_active (view, TRUE); \ \ bamf_view_export_on_bus (view, gdbus_connection); \ g_assert (bamf_view_is_active (view)); \ \ bamf_view_set_active (view, FALSE); \ g_assert (!bamf_view_is_active (view)); \ \ g_object_unref (view); \ } declare_test_boolean_property_exported (active); declare_test_boolean_property_exported (running); declare_test_boolean_property_exported (urgent); declare_test_boolean_property_exported (user_visible); static void test_path (void) { BamfView *view; const char *path; view = g_object_new (BAMF_TYPE_VIEW, NULL); g_assert (bamf_view_get_path (view) == NULL); path = bamf_view_export_on_bus (view, gdbus_connection); g_assert (path); g_assert (g_strcmp0 (path, bamf_view_get_path (view)) == 0); g_object_unref (view); } static void test_path_collision (void) { int i, j; for (i = 0; i < 20; i++) { GList *views = NULL; for (j = 0; j < 2000; j++) { BamfView * view = g_object_new (BAMF_TYPE_VIEW, NULL); g_assert (BAMF_IS_VIEW (view)); views = g_list_prepend (views, view); bamf_view_export_on_bus (view, gdbus_connection); } g_list_free_full (views, g_object_unref); } } static void test_children (void) { BamfView *parent; BamfView *child1, *child2, *child3; parent = g_object_new (BAMF_TYPE_VIEW, NULL); child1 = g_object_new (BAMF_TYPE_VIEW, NULL); child2 = g_object_new (BAMF_TYPE_VIEW, NULL); child3 = g_object_new (BAMF_TYPE_VIEW, NULL); g_assert (bamf_view_get_children (parent) == NULL); bamf_view_add_child (parent, child1); g_assert (g_list_length (bamf_view_get_children (parent)) == 1); g_assert (g_list_nth_data (bamf_view_get_children (parent), 0) == child1); bamf_view_add_child (parent, child2); bamf_view_add_child (parent, child3); g_assert (g_list_length (bamf_view_get_children (parent)) == 3); bamf_view_close (child1); g_object_unref (child1); g_assert (g_list_length (bamf_view_get_children (parent)) == 2); bamf_view_close (child2); g_object_unref (child2); g_assert (g_list_length (bamf_view_get_children (parent)) == 1); bamf_view_close (child3); g_object_unref (child3); g_assert (g_list_length (bamf_view_get_children (parent)) == 0); bamf_view_close (parent); g_object_unref (parent); } static void test_children_paths (void) { BamfView *parent; BamfView *child1, *child2, *child3; GVariant *container; GVariantIter *paths; const char *path; gboolean found; parent = g_object_new (BAMF_TYPE_VIEW, NULL); child1 = g_object_new (BAMF_TYPE_VIEW, NULL); child2 = g_object_new (BAMF_TYPE_VIEW, NULL); child3 = g_object_new (BAMF_TYPE_VIEW, NULL); bamf_view_export_on_bus (parent, gdbus_connection); bamf_view_export_on_bus (child1, gdbus_connection); bamf_view_export_on_bus (child2, gdbus_connection); g_assert (bamf_view_get_children (parent) == NULL); bamf_view_add_child (parent, child1); bamf_view_add_child (parent, child2); bamf_view_add_child (parent, child3); g_assert (g_list_length (bamf_view_get_children (parent)) == 3); container = bamf_view_get_children_paths (parent); g_assert (g_variant_type_equal (g_variant_get_type (container), G_VARIANT_TYPE ("(as)"))); g_assert (g_variant_n_children (container) == 1); g_variant_get (container, "(as)", &paths); g_assert (g_variant_iter_n_children (paths) == 2); g_variant_iter_free (paths); g_variant_unref (container); bamf_view_export_on_bus (child3, gdbus_connection); container = bamf_view_get_children_paths (parent); g_variant_get (container, "(as)", &paths); g_assert (g_variant_iter_n_children (paths) == 3); found = FALSE; while (g_variant_iter_loop (paths, "s", &path)) { if (g_strcmp0 (path, bamf_view_get_path (child1)) == 0) { found = TRUE; break; } } g_assert (found); found = FALSE; g_variant_get (container, "(as)", &paths); while (g_variant_iter_loop (paths, "s", &path)) { if (g_strcmp0 (path, bamf_view_get_path (child2)) == 0) { found = TRUE; break; } } g_variant_iter_free (paths); g_assert (found); found = FALSE; g_variant_get (container, "(as)", &paths); while (g_variant_iter_loop (paths, "s", &path)) { if (g_strcmp0 (path, bamf_view_get_path (child3)) == 0) { found = TRUE; break; } } g_variant_iter_free (paths); g_assert (found); g_variant_unref (container); g_object_unref (child1); g_object_unref (child2); g_object_unref (child3); g_object_unref (parent); } static gboolean boolean_event_fired = FALSE; static gboolean boolean_event_result = FALSE; static guint boolean_event_calls = 0; static void on_boolean_event (BamfView *view, gboolean event, gpointer pointer) { boolean_event_fired = TRUE; boolean_event_result = event; } #define test_boolean_property_event(prop) test_##prop##_event #define declare_test_boolean_property_event(prop) \ static void \ test_boolean_property_event (prop) (void) \ { \ BamfView *view; \ \ view = g_object_new (BAMF_TYPE_VIEW, NULL); \ g_assert (!bamf_view_is_##prop (view)); \ \ g_signal_connect (G_OBJECT (view), #prop "_changed", \ (GCallback) on_boolean_event, NULL); \ \ boolean_event_fired = FALSE; \ boolean_event_result = FALSE; \ \ bamf_view_set_##prop (view, TRUE); \ g_assert (bamf_view_is_##prop (view)); \ \ while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); \ g_assert (boolean_event_fired); \ g_assert (boolean_event_result); \ \ boolean_event_fired = FALSE; \ bamf_view_set_##prop (view, FALSE); \ g_assert (!bamf_view_is_##prop (view)); \ \ while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); \ g_assert (boolean_event_fired); \ g_assert (!boolean_event_result); \ \ g_object_unref (view); \ } declare_test_boolean_property_event (active); declare_test_boolean_property_event (running); declare_test_boolean_property_event (urgent); declare_test_boolean_property_event (user_visible); static gboolean string_event_fired = FALSE; static char * string_event_result = NULL; static void on_string_event (BamfView *view, const gchar *oval, const gchar *nval, gpointer pointer) { string_event_fired = TRUE; g_free (string_event_result); string_event_result = g_strdup (nval); } static void test_name_event (void) { BamfView *view; view = g_object_new (BAMF_TYPE_VIEW, NULL); g_assert (!bamf_view_get_name (view)); g_signal_connect (G_OBJECT (view), "name_changed", (GCallback) on_string_event, NULL); string_event_fired = FALSE; string_event_result = NULL; bamf_view_set_name (view, "NewName"); g_assert_cmpstr (bamf_view_get_name (view), ==, "NewName"); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (string_event_fired); g_assert_cmpstr (string_event_result, ==, "NewName"); string_event_fired = FALSE; bamf_view_set_name (view, "AnotherName"); g_assert_cmpstr (bamf_view_get_name (view), ==, "AnotherName"); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (string_event_fired); g_assert_cmpstr (string_event_result, ==, "AnotherName"); g_object_unref (view); } static gboolean property_event_fired = FALSE; static char * property_event_name = NULL; static void on_property_changed (BamfView *view, GParamSpec *param, BamfView *self) { g_free (property_event_name); property_event_fired = TRUE; property_event_name = g_strdup (param->name); } static void test_icon_event (void) { BamfView *view; view = g_object_new (BAMF_TYPE_VIEW, NULL); g_assert (!bamf_view_get_icon (view)); g_signal_connect (G_OBJECT (view), "notify::icon", (GCallback) on_property_changed, NULL); property_event_fired = FALSE; property_event_name = NULL; bamf_view_set_icon (view, "NewIcon"); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (property_event_fired); g_assert_cmpstr (property_event_name, ==, "icon"); property_event_fired = FALSE; bamf_view_set_icon (view, "AnotherIcon"); g_assert_cmpstr (bamf_view_get_icon (view), ==, "AnotherIcon"); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (property_event_fired); g_assert_cmpstr (property_event_name, ==, "icon"); g_object_unref (view); } #define test_boolean_property_event_exported(prop) test_##prop##_event_exported #define declare_test_boolean_property_event_exported(prop) \ static void \ test_boolean_property_event_exported (prop) (void) \ { \ BamfView *view; \ \ view = g_object_new (BAMF_TYPE_VIEW, NULL); \ g_assert (!bamf_view_is_##prop (view)); \ \ g_signal_connect (G_OBJECT (view), #prop "_changed", \ (GCallback) on_boolean_event, NULL); \ \ boolean_event_fired = FALSE; \ boolean_event_result = FALSE; \ \ bamf_view_set_##prop (view, TRUE); \ \ while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); \ g_assert (boolean_event_fired); \ g_assert (boolean_event_result); \ boolean_event_fired = FALSE; \ boolean_event_result = FALSE; \ \ bamf_view_export_on_bus (view, gdbus_connection); \ while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); \ g_assert (boolean_event_fired); \ g_assert (boolean_event_result); \ \ boolean_event_fired = FALSE; \ bamf_view_set_##prop (view, FALSE); \ g_assert (!bamf_view_is_##prop (view)); \ \ while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); \ g_assert (boolean_event_fired); \ g_assert (!boolean_event_result); \ \ g_object_unref (view); \ } declare_test_boolean_property_event_exported (active); declare_test_boolean_property_event_exported (running); declare_test_boolean_property_event_exported (urgent); declare_test_boolean_property_event_exported (user_visible); static void test_name_event_exported (void) { BamfView *view; view = g_object_new (BAMF_TYPE_VIEW, NULL); g_assert (!bamf_view_get_name (view)); g_signal_connect (G_OBJECT (view), "name_changed", (GCallback) on_string_event, NULL); string_event_fired = FALSE; string_event_result = NULL; bamf_view_set_name (view, "NewName"); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (string_event_fired); g_assert_cmpstr (string_event_result, ==, "NewName"); string_event_fired = FALSE; g_free (string_event_result); string_event_result = NULL; bamf_view_export_on_bus (view, gdbus_connection); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (string_event_fired); g_assert_cmpstr (string_event_result, ==, "NewName"); string_event_fired = FALSE; bamf_view_set_name (view, "AnotherName"); g_assert_cmpstr (bamf_view_get_name (view), ==, "AnotherName"); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (string_event_fired); g_assert_cmpstr (string_event_result, ==, "AnotherName"); g_object_unref (view); } static void test_icon_event_exported (void) { BamfView *view; view = g_object_new (BAMF_TYPE_VIEW, NULL); g_assert (!bamf_view_get_icon (view)); g_signal_connect (G_OBJECT (view), "notify::icon", (GCallback) on_property_changed, NULL); property_event_fired = FALSE; property_event_name = NULL; bamf_view_set_icon (view, "NewIcon"); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (property_event_fired); g_assert_cmpstr (property_event_name, ==, "icon"); property_event_fired = FALSE; g_free (property_event_name); property_event_name = NULL; bamf_view_export_on_bus (view, gdbus_connection); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (property_event_fired); g_assert_cmpstr (property_event_name, ==, "icon"); property_event_fired = FALSE; bamf_view_set_icon (view, "AnotherIcon"); g_assert_cmpstr (bamf_view_get_icon (view), ==, "AnotherIcon"); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (property_event_fired); g_assert_cmpstr (property_event_name, ==, "icon"); g_object_unref (view); } static void on_boolean_event_count (BamfView *view, gboolean event, gpointer pointer) { boolean_event_calls++; boolean_event_result = event; } static void test_active_event_count (void) { BamfView *view; view = g_object_new (BAMF_TYPE_VIEW, NULL); g_assert (!bamf_view_is_active (view)); g_signal_connect (G_OBJECT (view), "active-changed", (GCallback) on_boolean_event_count, NULL); boolean_event_calls = 0; bamf_view_set_active (view, TRUE); g_assert (bamf_view_is_active (view)); g_assert_cmpuint (boolean_event_calls, ==, 0); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert_cmpuint (boolean_event_calls, ==, 1); g_assert (boolean_event_result); boolean_event_calls = 0; bamf_view_set_active (view, FALSE); bamf_view_set_active (view, TRUE); bamf_view_set_active (view, FALSE); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert_cmpuint (boolean_event_calls, ==, 1); g_assert (!boolean_event_result); g_object_unref (view); } static gboolean child_added_event_fired; static char * child_added_event_result; static void on_child_added (BamfView *view, char *path, gpointer pointer) { child_added_event_fired = TRUE; child_added_event_result = g_strdup (path); } static void test_child_added_event (void) { BamfView *parent; BamfView *child; parent = g_object_new (BAMF_TYPE_VIEW, NULL); child = g_object_new (BAMF_TYPE_VIEW, NULL); bamf_view_export_on_bus (parent, gdbus_connection); bamf_view_export_on_bus (child, gdbus_connection); g_signal_connect (G_OBJECT (parent), "child-added", (GCallback) on_child_added, NULL); child_added_event_fired = FALSE; bamf_view_add_child (parent, child); g_assert (child_added_event_fired); g_assert (g_strcmp0 (bamf_view_get_path (child), child_added_event_result) == 0); bamf_view_close (child); bamf_view_close (parent); g_object_unref (child); g_object_unref (parent); } static gboolean child_removed_event_fired; static char * child_removed_event_result; static void on_child_removed (BamfView *view, char *path, gpointer pointer) { child_removed_event_fired = TRUE; child_removed_event_result = g_strdup (path); } static void test_child_removed_event (void) { BamfView *parent; BamfView *child; parent = g_object_new (BAMF_TYPE_VIEW, NULL); child = g_object_new (BAMF_TYPE_VIEW, NULL); bamf_view_export_on_bus (parent, gdbus_connection); bamf_view_export_on_bus (child, gdbus_connection); bamf_view_add_child (parent, child); g_signal_connect (G_OBJECT (parent), "child-removed", (GCallback) on_child_removed, NULL); child_removed_event_fired = FALSE; bamf_view_remove_child (parent, child); g_assert (child_removed_event_fired); g_assert (g_strcmp0 (bamf_view_get_path (child), child_removed_event_result) == 0); g_object_unref (child); g_object_unref (parent); } static gboolean closed_event_fired; static void on_closed (BamfView *view, gpointer pointer) { closed_event_fired = TRUE; } static void test_closed_event (void) { BamfView *view; view = g_object_new (BAMF_TYPE_VIEW, NULL); bamf_view_export_on_bus (view, gdbus_connection); g_signal_connect (G_OBJECT (view), "closed", (GCallback) on_closed, NULL); closed_event_fired = FALSE; bamf_view_close (view); g_assert (closed_event_fired); g_object_unref (view); } static void test_parent_child_out_of_order_unref (void) { BamfView *parent, *child; parent = g_object_new (BAMF_TYPE_VIEW, NULL); child = g_object_new (BAMF_TYPE_VIEW, NULL); bamf_view_export_on_bus (parent, gdbus_connection); bamf_view_export_on_bus (child, gdbus_connection); bamf_view_add_child (parent, child); g_object_unref (parent); g_object_unref (child); } /* Test Suite */ void test_view_create_suite (GDBusConnection *connection) { #define DOMAIN "/View" gdbus_connection = connection; g_test_add_func (DOMAIN"/Allocation", test_allocation); g_test_add_func (DOMAIN"/Name", test_string_property (name)); g_test_add_func (DOMAIN"/Name/Exported", test_string_property_exported (name)); g_test_add_func (DOMAIN"/Icon", test_string_property (icon)); g_test_add_func (DOMAIN"/Icon/Exported", test_string_property_exported (icon)); g_test_add_func (DOMAIN"/Active", test_boolean_property (active)); g_test_add_func (DOMAIN"/Active/Exported", test_boolean_property_exported (active)); g_test_add_func (DOMAIN"/Running", test_boolean_property (running)); g_test_add_func (DOMAIN"/Running/Exported", test_boolean_property_exported (running)); g_test_add_func (DOMAIN"/Urgent", test_boolean_property (urgent)); g_test_add_func (DOMAIN"/Urgent/Exported", test_boolean_property_exported (urgent)); g_test_add_func (DOMAIN"/UserVisible", test_boolean_property (user_visible)); g_test_add_func (DOMAIN"/UserVisible/Exported", test_boolean_property_exported (user_visible)); g_test_add_func (DOMAIN"/Path", test_path); g_test_add_func (DOMAIN"/Path/Collision", test_path_collision); g_test_add_func (DOMAIN"/Events/Close", test_closed_event); g_test_add_func (DOMAIN"/Events/Active", test_boolean_property_event (active)); g_test_add_func (DOMAIN"/Events/Name", test_name_event); g_test_add_func (DOMAIN"/Events/Name/Exported", test_name_event_exported); g_test_add_func (DOMAIN"/Events/Icon", test_icon_event); g_test_add_func (DOMAIN"/Events/Icon/Exported", test_icon_event_exported); g_test_add_func (DOMAIN"/Events/Active/Count", test_active_event_count); g_test_add_func (DOMAIN"/Events/Active/Exported", test_boolean_property_event_exported (active)); g_test_add_func (DOMAIN"/Events/Running", test_boolean_property_event (running)); g_test_add_func (DOMAIN"/Events/Running/Exported", test_boolean_property_event_exported (running)); g_test_add_func (DOMAIN"/Events/Urgent", test_boolean_property_event (urgent)); g_test_add_func (DOMAIN"/Events/Urgent/Exported", test_boolean_property_event_exported (urgent)); g_test_add_func (DOMAIN"/Events/UserVisible", test_boolean_property_event (user_visible)); g_test_add_func (DOMAIN"/Events/UserVisible/Exported", test_boolean_property_event_exported (user_visible)); g_test_add_func (DOMAIN"/Events/ChildAdded", test_child_added_event); g_test_add_func (DOMAIN"/Events/ChildRemoved", test_child_removed_event); g_test_add_func (DOMAIN"/Children", test_children); g_test_add_func (DOMAIN"/Children/Paths", test_children_paths); g_test_add_func (DOMAIN"/Children/UnrefOrder", test_parent_child_out_of_order_unref); } ./tests/bamfdaemon/test-window.c0000644000004100000410000002247014203512426017132 0ustar www-datawww-data/* * Copyright (C) 2009 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by Jason Smith * */ #include #include #include "bamf-window.h" #include "bamf-legacy-window.h" #include "bamf-legacy-window-test.h" static void test_allocation (void); static void test_xid (void); static void test_hints (void); static void test_active (void); static void test_urgent (void); static void test_user_visible (void); static void test_maximized (void); static void test_vmaximized (void); static void test_hmaximized (void); static void test_hmaximized (void); static gboolean signal_seen = FALSE; static gboolean signal_result = FALSE; void test_window_create_suite (void) { #define DOMAIN "/Window" g_test_add_func (DOMAIN"/Allocation", test_allocation); g_test_add_func (DOMAIN"/Xid", test_xid); g_test_add_func (DOMAIN"/Hints", test_hints); g_test_add_func (DOMAIN"/Events/Active", test_active); g_test_add_func (DOMAIN"/Events/Urgent", test_urgent); g_test_add_func (DOMAIN"/Events/UserVisible", test_user_visible); g_test_add_func (DOMAIN"/Events/Maximized", test_maximized); g_test_add_func (DOMAIN"/Events/VerticallyMaximized", test_vmaximized); g_test_add_func (DOMAIN"/Events/HorizontallyMaximized", test_hmaximized); } void test_allocation (void) { BamfWindow *window; BamfLegacyWindowTest *test; test = bamf_legacy_window_test_new (20,"Window X", "class", "exec"); window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); g_assert (BAMF_IS_WINDOW (window)); g_object_unref (window); g_object_unref (test); } void test_hints (void) { BamfWindow *window; BamfLegacyWindowTest *test; test = bamf_legacy_window_test_new (20,"Window X", "class", "exec"); window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); bamf_legacy_window_set_hint (BAMF_LEGACY_WINDOW (test), "HINT_NAME", "HINT_VALUE"); g_assert_cmpstr (bamf_window_get_string_hint (window, "HINT_NAME"), ==, "HINT_VALUE"); g_assert_cmpstr (bamf_window_get_string_hint (window, "INVALID_HINT_NAME"), ==, NULL); g_object_unref (window); g_object_unref (test); } void test_xid (void) { BamfWindow *window; BamfLegacyWindowTest *test; test = bamf_legacy_window_test_new (20,"Window X", "class", "exec"); window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); g_assert (bamf_window_get_xid (window) == 20); g_object_unref (window); g_object_unref (test); } void on_urgent_changed (BamfWindow *window, gboolean result, gpointer pointer) { signal_seen = TRUE; signal_result = result; } void test_urgent (void) { signal_seen = FALSE; BamfWindow *window; BamfLegacyWindowTest *test; test = bamf_legacy_window_test_new (20,"Window X", "class", "exec"); window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); g_signal_connect (G_OBJECT (window), "urgent-changed", (GCallback) on_urgent_changed, NULL); g_assert (!bamf_view_is_urgent (BAMF_VIEW (window))); g_assert (!signal_seen); bamf_legacy_window_test_set_attention (test, TRUE); g_assert (bamf_view_is_urgent (BAMF_VIEW (window))); g_assert (signal_seen); g_assert (signal_result); signal_seen = FALSE; bamf_legacy_window_test_set_attention (test, FALSE); g_assert (!bamf_view_is_urgent (BAMF_VIEW (window))); g_assert (signal_seen); g_assert (!signal_result); g_object_unref (window); g_object_unref (test); } void on_active_changed (BamfWindow *window, gboolean result, gpointer pointer) { signal_seen = TRUE; signal_result = result; } void test_active (void) { signal_seen = FALSE; BamfWindow *window; BamfLegacyWindowTest *test; test = bamf_legacy_window_test_new (20,"Window X", "class", "exec"); window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); g_signal_connect (G_OBJECT (window), "active-changed", (GCallback) on_active_changed, NULL); g_assert (!bamf_view_is_active (BAMF_VIEW (window))); g_assert (!signal_seen); bamf_legacy_window_test_set_active (test, TRUE); g_assert (bamf_view_is_active (BAMF_VIEW (window))); g_assert (!signal_seen); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (signal_seen); g_assert (signal_result); signal_seen = FALSE; bamf_legacy_window_test_set_active (test, FALSE); g_assert (!bamf_view_is_active (BAMF_VIEW (window))); g_assert (!signal_seen); while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); g_assert (signal_seen); g_assert (!signal_result); g_object_unref (window); g_object_unref (test); } void on_user_visible_changed (BamfWindow *window, gboolean result, gpointer pointer) { signal_seen = TRUE; signal_result = result; } void test_user_visible (void) { signal_seen = FALSE; BamfWindow *window; BamfLegacyWindowTest *test; test = bamf_legacy_window_test_new (20,"Window X", "class", "exec"); window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); g_signal_connect (G_OBJECT (window), "user-visible-changed", (GCallback) on_user_visible_changed, NULL); g_assert (bamf_view_is_user_visible (BAMF_VIEW (window))); g_assert (!signal_seen); bamf_legacy_window_test_set_skip (test, TRUE); g_assert (!bamf_view_is_user_visible (BAMF_VIEW (window))); g_assert (signal_seen); g_assert (!signal_result); signal_seen = FALSE; bamf_legacy_window_test_set_skip (test, FALSE); g_assert (bamf_view_is_user_visible (BAMF_VIEW (window))); g_assert (signal_seen); g_assert (signal_result); g_object_unref (window); g_object_unref (test); } void on_maximized_changed (BamfWindow *window, gint old, gint new, gpointer pointer) { signal_seen = TRUE; signal_result = (old == BAMF_WINDOW_FLOATING && new == BAMF_WINDOW_MAXIMIZED); } void test_maximized (void) { signal_seen = FALSE; BamfWindow *window; BamfLegacyWindowTest *test; test = bamf_legacy_window_test_new (20,"Maximized Window X", "class", "exec"); window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); g_signal_connect (G_OBJECT (window), "maximized-changed", (GCallback) on_maximized_changed, NULL); g_assert (bamf_window_maximized (window) == BAMF_WINDOW_FLOATING); g_assert (!signal_seen); bamf_legacy_window_test_set_maximized (test, BAMF_WINDOW_MAXIMIZED); g_assert (bamf_window_maximized (window) == BAMF_WINDOW_MAXIMIZED); g_assert (signal_seen); g_assert (signal_result); signal_seen = FALSE; bamf_legacy_window_test_set_maximized (test, BAMF_WINDOW_FLOATING); g_assert (bamf_window_maximized (window) == BAMF_WINDOW_FLOATING); g_assert (signal_seen); g_assert (!signal_result); g_object_unref (window); g_object_unref (test); } void on_vmaximized_changed (BamfWindow *window, gint old, gint new, gpointer pointer) { signal_seen = TRUE; signal_result = (old == BAMF_WINDOW_FLOATING && new == BAMF_WINDOW_VERTICAL_MAXIMIZED); } void test_vmaximized (void) { signal_seen = FALSE; BamfWindow *window; BamfLegacyWindowTest *test; test = bamf_legacy_window_test_new (20,"Maximized Window X", "class", "exec"); window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); g_signal_connect (G_OBJECT (window), "maximized-changed", (GCallback) on_vmaximized_changed, NULL); g_assert (bamf_window_maximized (window) == BAMF_WINDOW_FLOATING); g_assert (!signal_seen); bamf_legacy_window_test_set_maximized (test, BAMF_WINDOW_VERTICAL_MAXIMIZED); g_assert (bamf_window_maximized (window) == BAMF_WINDOW_VERTICAL_MAXIMIZED); g_assert (signal_seen); g_assert (signal_result); signal_seen = FALSE; bamf_legacy_window_test_set_maximized (test, BAMF_WINDOW_FLOATING); g_assert (bamf_window_maximized (window) == BAMF_WINDOW_FLOATING); g_assert (signal_seen); g_assert (!signal_result); g_object_unref (window); g_object_unref (test); } void on_hmaximized_changed (BamfWindow *window, gint old, gint new, gpointer pointer) { signal_seen = TRUE; signal_result = (old == BAMF_WINDOW_FLOATING && new == BAMF_WINDOW_HORIZONTAL_MAXIMIZED); } void test_hmaximized (void) { signal_seen = FALSE; BamfWindow *window; BamfLegacyWindowTest *test; test = bamf_legacy_window_test_new (20,"Maximized Window X", "class", "exec"); window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); g_signal_connect (G_OBJECT (window), "maximized-changed", (GCallback) on_hmaximized_changed, NULL); g_assert (bamf_window_maximized (window) == BAMF_WINDOW_FLOATING); g_assert (!signal_seen); bamf_legacy_window_test_set_maximized (test, BAMF_WINDOW_HORIZONTAL_MAXIMIZED); g_assert (bamf_window_maximized (window) == BAMF_WINDOW_HORIZONTAL_MAXIMIZED); g_assert (signal_seen); g_assert (signal_result); signal_seen = FALSE; bamf_legacy_window_test_set_maximized (test, BAMF_WINDOW_FLOATING); g_assert (bamf_window_maximized (window) == BAMF_WINDOW_FLOATING); g_assert (signal_seen); g_assert (!signal_result); g_object_unref (window); g_object_unref (test); } ./tests/bamfdaemon/test-application.c0000644000004100000410000014365214203512426020134 0ustar www-datawww-data/* * Copyright (C) 2009-2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by Jason Smith * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> * */ #include #include #include #include #include "bamf-application.h" #include "bamf-window.h" #include "bamf-legacy-window.h" #include "bamf-legacy-window-test.h" #define DESKTOP_FILE TESTDIR"/data/test-bamf-app.desktop" void ignore_fatal_errors (void); static gboolean signal_seen = FALSE; static gboolean signal_result = FALSE; static GDBusConnection * gdbus_connection = NULL; static GFile * write_data_to_tmp_file (const gchar *data) { GFile *tmp; GFileIOStream *iostream; GOutputStream *output; tmp = g_file_new_tmp (NULL, &iostream, NULL); if (!tmp) { if (iostream) g_object_unref (iostream); return NULL; } output = g_io_stream_get_output_stream (G_IO_STREAM (iostream)); if (!g_output_stream_write_all (output, data, strlen (data), NULL, NULL, NULL)) { g_object_unref (tmp); tmp = NULL; } g_object_unref (output); return tmp; } static void test_allocation (void) { BamfApplication *application; /* Check it allocates */ application = bamf_application_new (); g_assert (BAMF_IS_APPLICATION (application)); g_object_unref (application); application = bamf_application_new_from_desktop_file (DESKTOP_FILE); g_assert (BAMF_IS_APPLICATION (application)); g_object_unref (application); } static void test_type (void) { BamfApplication *application = bamf_application_new (); g_assert_cmpuint (bamf_application_get_application_type (application), ==, BAMF_APPLICATION_SYSTEM); g_object_unref (application); } static void test_type_set (void) { BamfApplication *application = bamf_application_new (); bamf_application_set_application_type (application, BAMF_APPLICATION_WEB); g_assert_cmpuint (bamf_application_get_application_type (application), ==, BAMF_APPLICATION_WEB); bamf_application_set_application_type (application, BAMF_APPLICATION_SYSTEM); g_assert_cmpuint (bamf_application_get_application_type (application), ==, BAMF_APPLICATION_SYSTEM); g_object_unref (application); } static void test_type_set_invalid (void) { ignore_fatal_errors(); BamfApplication *application = bamf_application_new (); bamf_application_set_application_type (application, BAMF_APPLICATION_UNKNOWN); g_assert_cmpuint (bamf_application_get_application_type (application), ==, BAMF_APPLICATION_SYSTEM); bamf_application_set_application_type (application, -1); g_assert_cmpuint (bamf_application_get_application_type (application), ==, BAMF_APPLICATION_SYSTEM); g_object_unref (application); } static void test_desktop_file (void) { BamfApplication *application = bamf_application_new (); g_assert (bamf_application_get_desktop_file (application) == NULL); bamf_application_set_desktop_file (application, DESKTOP_FILE); g_assert (g_strcmp0 (bamf_application_get_desktop_file (application), DESKTOP_FILE) == 0); g_object_unref (application); application = bamf_application_new_from_desktop_file (DESKTOP_FILE); g_assert (g_strcmp0 (bamf_application_get_desktop_file (application), DESKTOP_FILE) == 0); g_object_unref (application); } static void test_desktop_icon (void) { BamfApplication *application; const char *icon_desktop = TESTDIR"/data/icon.desktop"; application = bamf_application_new_from_desktop_file (icon_desktop); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); g_object_unref (application); } static void test_desktop_icon_empty (void) { BamfApplication *application; const char no_icon_desktop[] = TESTDIR"/data/no-icon.desktop"; application = bamf_application_new_from_desktop_file (no_icon_desktop); g_assert_cmpstr (bamf_application_get_desktop_file (application), ==, no_icon_desktop); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, BAMF_APPLICATION_DEFAULT_ICON); g_object_unref (application); } static void test_desktop_icon_invalid (void) { BamfApplication *application; const char *invalid_icon_desktop = TESTDIR"/data/test-bamf-app.desktop"; application = bamf_application_new_from_desktop_file (invalid_icon_desktop); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, BAMF_APPLICATION_DEFAULT_ICON); g_object_unref (application); } static void test_icon_class_name (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *test; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); g_object_unref (lwin); g_object_unref (test); g_object_unref (application); } static void test_icon_exec_string (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *test; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "class", "test-bamf-icon"); test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); g_object_unref (lwin); g_object_unref (test); g_object_unref (application); } static void test_icon_embedded (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *test; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "class", "python execution-script.py"); bamf_legacy_window_test_set_icon (lwin, "test-bamf-icon"); test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); g_object_unref (lwin); g_object_unref (test); g_object_unref (application); } static void test_icon_priority (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *test; lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "test-bamf-pixmap"); bamf_legacy_window_test_set_icon (lwin, "bamf-custom-icon"); test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); application = bamf_application_new (); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); g_object_unref (application); application = bamf_application_new (); bamf_legacy_window_test_set_wmclass (lwin, NULL, NULL); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-pixmap"); g_object_unref (application); application = bamf_application_new (); g_free (lwin->exec); lwin->exec = NULL; bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "bamf-custom-icon"); g_object_unref (application); g_object_unref (lwin); g_object_unref (test); } static void test_icon_generic_class (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *test; lwin = bamf_legacy_window_test_new (20, "window", "python", "execution-script"); test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); application = bamf_application_new (); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "python"); g_object_unref (application); application = bamf_application_new (); bamf_legacy_window_test_set_icon (lwin, "bamf-custom-icon"); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "bamf-custom-icon"); g_object_unref (application); g_object_unref (lwin); g_object_unref (test); } static void test_icon_generic_exec (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *test; lwin = bamf_legacy_window_test_new (20, "window", "class", "python2.7"); test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); application = bamf_application_new (); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "python2.7"); g_object_unref (application); application = bamf_application_new (); bamf_legacy_window_test_set_icon (lwin, "bamf-custom-icon"); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "bamf-custom-icon"); g_object_unref (application); g_object_unref (lwin); g_object_unref (test); } static void test_icon_full_path (void) { BamfApplication *application; GKeyFile *key_file; const char* test_app = TESTDIR"/data/test-bamf-app.desktop"; const char* test_icon = TESTDIR"/data/icons/test-bamf-icon.png"; g_assert (g_file_test (test_icon, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); key_file = g_key_file_new (); g_key_file_load_from_file (key_file, test_app, G_KEY_FILE_NONE, NULL); g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, test_icon); gchar *key_data = g_key_file_to_data (key_file, NULL, NULL); GFile *tmp_file = write_data_to_tmp_file (key_data); gchar *path = g_file_get_path (tmp_file); application = bamf_application_new_from_desktop_file (path); g_file_delete (tmp_file, NULL, NULL); g_object_unref (tmp_file); g_key_file_free (key_file); g_free (key_data); g_free (path); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, test_icon); g_object_unref (application); } static void test_icon_full_path_invalid (void) { BamfApplication *application; GKeyFile *key_file; const char* test_app = TESTDIR"/data/test-bamf-app.desktop"; const char* invalid_test_icon = TESTDIR"/data/icons/not-existent-icon-file.png"; g_assert (!g_file_test (invalid_test_icon, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); key_file = g_key_file_new (); g_key_file_load_from_file (key_file, test_app, G_KEY_FILE_NONE, NULL); g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, invalid_test_icon); gchar *key_data = g_key_file_to_data (key_file, NULL, NULL); GFile *tmp_file = write_data_to_tmp_file (key_data); gchar *path = g_file_get_path (tmp_file); application = bamf_application_new_from_desktop_file (path); g_file_delete (tmp_file, NULL, NULL); g_object_unref (tmp_file); g_key_file_free (key_file); g_free (key_data); g_free (path); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, BAMF_APPLICATION_DEFAULT_ICON); g_object_unref (application); } static void test_get_mime_types (void) { BamfApplication *application; const char* mime_types_desktop = TESTDIR"/data/mime-types.desktop"; application = bamf_application_new_from_desktop_file (mime_types_desktop); g_assert_cmpstr (bamf_application_get_desktop_file (application), ==, mime_types_desktop); gchar** mimes = bamf_application_get_supported_mime_types (application); g_assert_cmpuint (g_strv_length (mimes), ==, 7); g_assert_cmpstr (mimes[0], ==, "text/plain"); g_assert_cmpstr (mimes[1], ==, "text/x-chdr"); g_assert_cmpstr (mimes[2], ==, "text/x-csrc"); g_assert_cmpstr (mimes[3], ==, "text/html"); g_assert_cmpstr (mimes[4], ==, "text/css"); g_assert_cmpstr (mimes[5], ==, "text/x-diff"); g_assert_cmpstr (mimes[6], ==, "application/xml"); g_assert_cmpstr (mimes[7], ==, NULL); g_strfreev (mimes); g_object_unref (application); } static void test_get_mime_types_none (void) { BamfApplication *application; const char* mime_types_desktop = TESTDIR"/data/test-bamf-app.desktop"; application = bamf_application_new_from_desktop_file (mime_types_desktop); g_assert_cmpstr (bamf_application_get_desktop_file (application), ==, mime_types_desktop); gchar** mimes = bamf_application_get_supported_mime_types (application); g_assert (!mimes); g_object_unref (application); } static void on_urgent_changed (BamfApplication *application, gboolean result, gpointer data) { signal_seen = TRUE; signal_result = result; } static void test_urgent (void) { signal_seen = FALSE; BamfApplication *application; BamfWindow *window1, *window2; BamfLegacyWindowTest *test1, *test2; application = bamf_application_new (); g_signal_connect (G_OBJECT (application), "urgent-changed", (GCallback) on_urgent_changed, NULL); g_assert (bamf_view_export_on_bus (BAMF_VIEW (application), gdbus_connection)); test1 = bamf_legacy_window_test_new (20, "Window X", "class", "exec"); test2 = bamf_legacy_window_test_new (21, "Window Y", "class", "exec"); window1 = bamf_window_new (BAMF_LEGACY_WINDOW (test1)); window2 = bamf_window_new (BAMF_LEGACY_WINDOW (test2)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (window1), gdbus_connection)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (window2), gdbus_connection)); // Ensure we are not visible with no windows g_assert (!bamf_view_is_urgent (BAMF_VIEW (application))); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); // Test that when added, we signaled properly g_assert (!bamf_view_is_urgent (BAMF_VIEW (application))); g_assert (!signal_seen); bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (window1)); // Test that we unset and signal properly g_assert (!bamf_view_is_urgent (BAMF_VIEW (application))); g_assert (!signal_seen); bamf_legacy_window_test_set_attention (test1, TRUE); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); // Ensure that when adding a skip-tasklist window, we dont set this to visible g_assert (bamf_view_is_urgent (BAMF_VIEW (application))); g_assert (signal_seen); g_assert (signal_result); signal_seen = FALSE; bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window2)); g_assert (bamf_view_is_urgent (BAMF_VIEW (application))); g_assert (!signal_seen); bamf_legacy_window_test_set_attention (test1, FALSE); g_assert (!bamf_view_is_urgent (BAMF_VIEW (application))); g_assert (signal_seen); g_assert (!signal_result); g_object_unref (window1); g_object_unref (window2); g_object_unref (application); } static void on_active_changed (BamfApplication *application, gboolean result, gpointer data) { signal_seen = TRUE; signal_result = result; } static void test_active (void) { signal_seen = FALSE; BamfApplication *application; BamfWindow *window1, *window2; BamfLegacyWindowTest *test1, *test2; application = bamf_application_new (); g_assert (bamf_view_export_on_bus (BAMF_VIEW (application), gdbus_connection)); g_signal_connect (G_OBJECT (application), "active-changed", (GCallback) on_active_changed, NULL); test1 = bamf_legacy_window_test_new (20, "Window X", "class", "exec"); test2 = bamf_legacy_window_test_new (21, "Window Y", "class", "exec"); window1 = bamf_window_new (BAMF_LEGACY_WINDOW (test1)); window2 = bamf_window_new (BAMF_LEGACY_WINDOW (test2)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (window1), gdbus_connection)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (window2), gdbus_connection)); // Ensure we are not active with no windows g_assert (!bamf_view_is_active (BAMF_VIEW (application))); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); // Test that when added, we signaled properly g_assert (!bamf_view_is_active (BAMF_VIEW (application))); g_assert (!signal_seen); bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (window1)); // Test that we unset and signal properly g_assert (!bamf_view_is_active (BAMF_VIEW (application))); g_assert (!signal_seen); bamf_legacy_window_test_set_active (test1, TRUE); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); // Ensure that when adding a skip-tasklist window, we dont set this to visible g_assert (bamf_view_is_active (BAMF_VIEW (application))); g_assert (!signal_seen); while (g_main_context_pending (NULL)) g_main_context_iteration(NULL, TRUE); g_assert (signal_seen); g_assert (signal_result); signal_seen = FALSE; bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window2)); g_assert (bamf_view_is_active (BAMF_VIEW (application))); g_assert (!signal_seen); bamf_legacy_window_test_set_active (test1, FALSE); g_assert (!signal_seen); g_assert (bamf_view_is_active (BAMF_VIEW (application))); while (g_main_context_pending (NULL)) g_main_context_iteration(NULL, TRUE); g_assert (!bamf_view_is_active (BAMF_VIEW (application))); g_assert (signal_seen); g_assert (!signal_result); g_object_unref (window1); g_object_unref (window2); g_object_unref (application); } static void test_get_xids (void) { BamfApplication *application; BamfWindow *window1, *window2; BamfLegacyWindowTest *lwin1, *lwin2; GVariant *container; GVariantIter *xids; gboolean found; guint32 xid; application = bamf_application_new (); lwin1 = bamf_legacy_window_test_new (25, "window1", "class", "exec"); lwin2 = bamf_legacy_window_test_new (50, "window2", "class", "exec"); window1 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin1)); window2 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin2)); container = bamf_application_get_xids (application); g_assert (g_variant_type_equal (g_variant_get_type (container), G_VARIANT_TYPE ("(au)"))); g_assert (g_variant_n_children (container) == 1); g_variant_get (container, "(au)", &xids); g_assert (g_variant_iter_n_children (xids) == 0); g_variant_iter_free (xids); g_variant_unref (container); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window2)); container = bamf_application_get_xids (application); g_assert (g_variant_n_children (container) == 1); g_variant_get (container, "(au)", &xids); g_assert (g_variant_iter_n_children (xids) == 2); found = FALSE; while (g_variant_iter_loop (xids, "u", &xid)) { if (xid == 25) { found = TRUE; break; } } g_assert (found); found = FALSE; g_variant_get (container, "(au)", &xids); while (g_variant_iter_loop (xids, "u", &xid)) { if (xid == 50) { found = TRUE; break; } } g_assert (found); g_variant_iter_free (xids); g_variant_unref (container); g_object_unref (lwin1); g_object_unref (lwin2); g_object_unref (window1); g_object_unref (window2); g_object_unref (application); } static void test_manages_xid (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *test; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "class", "exec"); test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert (bamf_application_manages_xid (application, 20)); g_object_unref (lwin); g_object_unref (test); g_object_unref (application); } static void test_get_window (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *test; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "class", "exec"); test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); g_assert (bamf_application_get_window (application, 20) == test); g_object_unref (lwin); g_object_unref (test); g_object_unref (application); } static void on_user_visible_changed (BamfApplication *application, gboolean result, gpointer data) { signal_seen = TRUE; signal_result = result; } static void test_user_visible (void) { signal_seen = FALSE; BamfApplication *application; BamfWindow *window1, *window2; BamfLegacyWindowTest *test1, *test2; application = bamf_application_new (); g_assert (bamf_view_export_on_bus (BAMF_VIEW (application), gdbus_connection)); g_signal_connect (G_OBJECT (application), "user-visible-changed", (GCallback) on_user_visible_changed, NULL); test1 = bamf_legacy_window_test_new (20, "Window X", "class", "exec"); test2 = bamf_legacy_window_test_new (21, "Window Y", "class", "exec"); window1 = bamf_window_new (BAMF_LEGACY_WINDOW (test1)); window2 = bamf_window_new (BAMF_LEGACY_WINDOW (test2)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (window1), gdbus_connection)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (window2), gdbus_connection)); // Ensure we are not visible with no windows g_assert (!bamf_view_is_user_visible (BAMF_VIEW (application))); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); // Test that when added, we signaled properly g_assert (bamf_view_is_user_visible (BAMF_VIEW (application))); g_assert (signal_seen); g_assert (signal_result); signal_seen = FALSE; bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (window1)); // Test that we unset and signal properly g_assert (!bamf_view_is_user_visible (BAMF_VIEW (application))); g_assert (signal_seen); g_assert (!signal_result); signal_seen = FALSE; bamf_legacy_window_test_set_skip (test1, TRUE); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); // Ensure that when adding a skip-tasklist window, we dont set this to visible g_assert (!bamf_view_is_user_visible (BAMF_VIEW (application))); g_assert (!signal_seen); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window2)); g_assert (bamf_view_is_user_visible (BAMF_VIEW (application))); g_assert (signal_seen); g_assert (signal_result); signal_seen = FALSE; bamf_legacy_window_test_set_skip (test2, TRUE); g_assert (!bamf_view_is_user_visible (BAMF_VIEW (window1))); g_assert (!bamf_view_is_user_visible (BAMF_VIEW (application))); g_assert (signal_seen); g_assert (!signal_result); g_object_unref (window1); g_object_unref (window2); g_object_unref (application); } static void test_desktop_app_main_child (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; application = bamf_application_new_from_desktop_file (DESKTOP_FILE); lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_assert (!bamf_application_get_main_child (application)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win)); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_desktop_app_main_child_doesnt_match_emblems (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; application = bamf_application_new_from_desktop_file (DESKTOP_FILE); lwin = bamf_legacy_window_test_new (20, "window", "python", "execution-binary"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), !=, "window"); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), !=, "python"); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_desktop_app_main_child_doesnt_update_emblems (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; application = bamf_application_new_from_desktop_file (DESKTOP_FILE); lwin = bamf_legacy_window_test_new (20, "window", "python", "execution-binary"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); bamf_legacy_window_test_set_name (lwin, "New Window Name"); g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), !=, "New Window Name"); bamf_legacy_window_test_set_name (lwin, "even-new-name"); g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), !=, "even-new-name"); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_app_main_child (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_assert (!bamf_application_get_main_child (application)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win)); g_object_unref (lwin); g_object_unref (win); g_assert (!bamf_application_get_main_child (application)); g_object_unref (application); } static void test_app_main_child_matches_emblems (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "window"); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_app_main_child_updates_emblems (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); bamf_legacy_window_test_set_name (lwin, "New Window Name"); g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "New Window Name"); bamf_legacy_window_test_set_name (lwin, "even-new-name"); g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "even-new-name"); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_app_main_child_multiple_children (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win1; GList *wins = NULL; GList *lwins = NULL; int i; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); win1 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_object_unref (lwin); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win1)); for (i = 0; i < 10; ++i) { lwin = bamf_legacy_window_test_new (i, "other-window", "", "execution-binary"); lwins = g_list_prepend (lwins, lwin); wins = g_list_prepend (wins, bamf_window_new (BAMF_LEGACY_WINDOW (lwin))); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (wins->data)); g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win1)); g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "window"); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); } g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win1)); g_object_unref (win1); g_object_unref (application); g_list_free_full (wins, g_object_unref); g_list_free_full (lwins, g_object_unref); } static void test_app_main_child_normal_priority (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *dialog, *win; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (10, "dialog", "python", "execution-binary"); lwin->window_type = BAMF_WINDOW_DIALOG; dialog = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_object_unref (lwin); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (dialog)); g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (dialog)); g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "dialog"); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "python"); lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_object_unref (lwin); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win)); g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "window"); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); g_object_unref (dialog); g_object_unref (win); g_object_unref (application); } static void test_app_main_child_on_window_removal (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win1, *win2, *win3, *win4, *dialog; application = bamf_application_new (); g_assert (bamf_view_export_on_bus (BAMF_VIEW (application), gdbus_connection)); lwin = bamf_legacy_window_test_new (10, "window1", NULL, "execution-binary"); win1 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (win1), gdbus_connection)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win1)); g_object_unref (lwin); lwin = bamf_legacy_window_test_new (20, "window2", NULL, "execution-binary"); win2 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (win2), gdbus_connection)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win2)); g_object_unref (lwin); lwin = bamf_legacy_window_test_new (21, "dialog", NULL, "execution-binary"); lwin->window_type = BAMF_WINDOW_DIALOG; dialog = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (dialog), gdbus_connection)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (dialog)); g_object_unref (lwin); lwin = bamf_legacy_window_test_new (30, "window3", NULL, "execution-binary"); win3 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (win3), gdbus_connection)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win3)); g_object_unref (lwin); lwin = bamf_legacy_window_test_new (40, "window4", NULL, "execution-binary"); win4 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (win4), gdbus_connection)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win4)); g_object_unref (lwin); g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win1)); bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (win4)); g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win1)); bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (win1)); g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win2)); bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (win2)); g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win3)); bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (win3)); g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (dialog)); bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (dialog)); g_assert (!bamf_application_get_main_child (application)); g_object_unref (win1); g_object_unref (win2); g_object_unref (win3); g_object_unref (win4); g_object_unref (dialog); g_object_unref (application); } static void test_app_main_child_on_window_replace_on_removal (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (win), gdbus_connection)); bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (!bamf_application_get_main_child (application)); bamf_legacy_window_test_set_name (lwin, "don't crash here!"); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_desktop_app_create_local_desktop_file (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; application = bamf_application_new (); bamf_application_set_desktop_file (application, DESKTOP_FILE); lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-class", "execution-binary"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (win), gdbus_connection)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (!bamf_application_create_local_desktop_file (application)); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_desktopless_app_create_local_desktop_file_invalid_exec (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-class", NULL); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_assert (bamf_view_export_on_bus (BAMF_VIEW (win), gdbus_connection)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (!bamf_application_create_local_desktop_file (application)); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void verify_application_desktop_file_content (BamfApplication *application) { GKeyFile *key_file; const gchar *desktop_file, *exec; gchar *str_value; GError *error = NULL; BamfView *main_child; BamfLegacyWindow *main_window; desktop_file = bamf_application_get_desktop_file (application); key_file = g_key_file_new (); g_key_file_load_from_file (key_file, desktop_file, G_KEY_FILE_NONE, &error); g_assert (!error); str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TYPE, &error); g_assert (!error); g_assert_cmpstr (str_value, ==, G_KEY_FILE_DESKTOP_TYPE_APPLICATION); g_clear_pointer (&str_value, g_free); str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, "Encoding", &error); g_assert (!error); g_assert_cmpstr (str_value, ==, "UTF-8"); g_clear_pointer (&str_value, g_free); str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_VERSION, &error); g_assert (!error); g_assert_cmpstr (str_value, ==, "1.0"); g_clear_pointer (&str_value, g_free); if (bamf_view_get_name (BAMF_VIEW (application))) { str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, &error); g_assert (!error); g_assert_cmpstr (str_value, ==, bamf_view_get_name (BAMF_VIEW (application))); g_clear_pointer (&str_value, g_free); } if (bamf_view_get_icon (BAMF_VIEW (application))) { str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, &error); g_assert (!error); g_assert_cmpstr (str_value, ==, bamf_view_get_icon (BAMF_VIEW (application))); g_clear_pointer (&str_value, g_free); } main_child = bamf_application_get_main_child (application); main_window = bamf_window_get_window (BAMF_WINDOW (main_child)); exec = bamf_legacy_window_get_exec_string (main_window); str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, &error); g_assert (!error); g_assert_cmpstr (str_value, ==, exec); g_clear_pointer (&str_value, g_free); const gchar *working_dir = bamf_legacy_window_get_working_dir (main_window); str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_PATH, &error); gchar *current_dir = g_get_current_dir (); if (g_strcmp0 (current_dir, working_dir) == 0) { g_assert (error); g_clear_error (&error); g_assert_cmpstr (str_value, ==, NULL); } else { g_assert (!error); g_assert_cmpstr (str_value, ==, working_dir); g_clear_pointer (&str_value, g_free); } g_clear_pointer (¤t_dir, g_free); g_assert (!g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY, &error)); g_assert (!error); const gchar *class = bamf_legacy_window_get_class_instance_name (main_window); class = class ? class : bamf_legacy_window_get_class_name (main_window); if (class) { str_value = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS, &error); g_assert (!error); g_assert_cmpstr (str_value, ==, class); g_clear_pointer (&str_value, g_free); } gchar *current_desktop = g_strdup (g_getenv ("XDG_CURRENT_DESKTOP")); if (current_desktop) { gchar **list; gsize len; gchar** desktops_list = g_strsplit (current_desktop, ":", 0); int i; current_desktop = g_strdup (desktops_list[0]); list = g_key_file_get_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN, &len, &error); g_assert (!error); g_assert_cmpuint (len, ==, g_strv_length (desktops_list)); for (i = 0; i < len; i++) g_assert_cmpstr (desktops_list[i], ==, list[i]); g_strfreev (desktops_list); g_strfreev (list); } gchar *generator = g_strdup_printf ("X-%s-Generated", current_desktop ? current_desktop : "BAMF"); g_assert (g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, generator, &error)); g_assert (!error); g_free (current_desktop); g_free (generator); g_key_file_free (key_file); } static void test_desktopless_app_create_local_desktop_file_using_instance_class_basename (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; const gchar *desktop_path; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", NULL, "awesome --exec"); bamf_legacy_window_test_set_wmclass (lwin, NULL, "instance-class"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (bamf_application_create_local_desktop_file (application)); desktop_path = bamf_application_get_desktop_file (application); g_assert (desktop_path); g_assert (g_str_has_suffix (desktop_path, "instance-class.desktop")); g_assert (g_file_test (desktop_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); verify_application_desktop_file_content (application); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_desktopless_app_create_local_desktop_file_using_name_class_basename (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; const gchar *desktop_path; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", "Application!/?Class", "awesome --exec"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (bamf_application_create_local_desktop_file (application)); desktop_path = bamf_application_get_desktop_file (application); g_assert (desktop_path); g_assert (g_str_has_suffix (desktop_path, "application___class.desktop")); g_assert (g_file_test (desktop_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); verify_application_desktop_file_content (application); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_desktopless_app_create_local_desktop_file_using_exec_basename (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; const gchar *desktop_path; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", NULL, "awesome --exec"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (bamf_application_create_local_desktop_file (application)); desktop_path = bamf_application_get_desktop_file (application); g_assert (desktop_path); g_assert (g_str_has_suffix (desktop_path, "awesome.desktop")); g_assert (g_file_test (desktop_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); verify_application_desktop_file_content (application); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_desktopless_app_create_local_desktop_file_using_trimmed_exec_basename (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; const gchar *desktop_path; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", NULL, "python awesome-script.py"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (bamf_application_create_local_desktop_file (application)); desktop_path = bamf_application_get_desktop_file (application); g_assert (desktop_path); g_assert (g_str_has_suffix (desktop_path, "awesome-script.desktop")); g_assert (g_file_test (desktop_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)); verify_application_desktop_file_content (application); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_desktopless_app_create_local_desktop_file_with_working_dir (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", NULL, "python ./awesome-script.py"); g_clear_pointer (&lwin->working_dir, g_free); lwin->working_dir = g_strdup ("/home/user/my/fantastic/path"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_assert (bamf_application_create_local_desktop_file (application)); verify_application_desktop_file_content (application); g_object_unref (lwin); g_object_unref (win); g_object_unref (application); } static void test_contain_similar_to_window (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win, *win1, *win2, *win3; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", NULL, "binary"); bamf_legacy_window_test_set_wmclass (lwin, "ClassName", "ClassInstance"); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_object_unref (lwin); lwin = bamf_legacy_window_test_new (30, "window1", NULL, "binary1"); bamf_legacy_window_test_set_wmclass (lwin, "ClassName", "ClassInstance"); win1 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_object_unref (lwin); g_assert (bamf_application_contains_similar_to_window (application, win1)); lwin = bamf_legacy_window_test_new (40, "window2", NULL, "binary2"); bamf_legacy_window_test_set_wmclass (lwin, "ClassName", "ClassInstance2"); win2 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_object_unref (lwin); g_assert (!bamf_application_contains_similar_to_window (application, win2)); lwin = bamf_legacy_window_test_new (50, "window3", NULL, "binary3"); bamf_legacy_window_test_set_wmclass (lwin, "ClassName3", "ClassInstance"); win3 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_object_unref (lwin); g_assert (!bamf_application_contains_similar_to_window (application, win3)); g_object_unref (win); g_object_unref (win1); g_object_unref (win2); g_object_unref (win3); g_object_unref (application); } static void test_contain_similar_to_window_null (void) { BamfApplication *application; BamfLegacyWindowTest *lwin; BamfWindow *win, *win1, *win2, *win3; application = bamf_application_new (); lwin = bamf_legacy_window_test_new (20, "window", NULL, "binary"); bamf_legacy_window_test_set_wmclass (lwin, NULL, NULL); win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); g_object_unref (lwin); lwin = bamf_legacy_window_test_new (30, "window1", NULL, "binary1"); bamf_legacy_window_test_set_wmclass (lwin, NULL, NULL); win1 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_object_unref (lwin); g_assert (bamf_application_contains_similar_to_window (application, win1)); lwin = bamf_legacy_window_test_new (40, "window2", NULL, "binary2"); bamf_legacy_window_test_set_wmclass (lwin, "ClassName", NULL); win2 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_object_unref (lwin); g_assert (!bamf_application_contains_similar_to_window (application, win2)); lwin = bamf_legacy_window_test_new (50, "window3", NULL, "binary3"); bamf_legacy_window_test_set_wmclass (lwin, NULL, "ClassInstance"); win3 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); g_object_unref (lwin); g_assert (!bamf_application_contains_similar_to_window (application, win3)); g_object_unref (win); g_object_unref (win1); g_object_unref (win2); g_object_unref (win3); g_object_unref (application); } /* Initialize test suite */ void test_application_create_suite (GDBusConnection *connection) { #define DOMAIN "/Application" gdbus_connection = connection; g_test_add_func (DOMAIN"/Allocation", test_allocation); g_test_add_func (DOMAIN"/ContainsSimilarToWindow", test_contain_similar_to_window); g_test_add_func (DOMAIN"/ContainsSimilarToWindow/Null", test_contain_similar_to_window_null); g_test_add_func (DOMAIN"/Type", test_type); g_test_add_func (DOMAIN"/Type/Set", test_type_set); g_test_add_func (DOMAIN"/Type/Set/Invalid", test_type_set_invalid); g_test_add_func (DOMAIN"/DesktopFile", test_desktop_file); g_test_add_func (DOMAIN"/DesktopFile/Icon", test_desktop_icon); g_test_add_func (DOMAIN"/DesktopFile/Icon/Empty", test_desktop_icon_empty); g_test_add_func (DOMAIN"/DesktopFile/Icon/Invalid", test_desktop_icon_invalid); g_test_add_func (DOMAIN"/DesktopFile/Icon/FullPath", test_icon_full_path); g_test_add_func (DOMAIN"/DesktopFile/Icon/FullPath/Invalid", test_icon_full_path_invalid); g_test_add_func (DOMAIN"/DesktopFile/MimeTypes/Valid", test_get_mime_types); g_test_add_func (DOMAIN"/DesktopFile/MimeTypes/None", test_get_mime_types_none); g_test_add_func (DOMAIN"/DesktopFile/MainChild", test_desktop_app_main_child); g_test_add_func (DOMAIN"/DesktopFile/MainChild/NotMatchEmblems", test_desktop_app_main_child_doesnt_match_emblems); g_test_add_func (DOMAIN"/DesktopFile/MainChild/NotUpdatesEmblems", test_desktop_app_main_child_doesnt_update_emblems); g_test_add_func (DOMAIN"/DesktopFile/CreateLocalDesktopFile", test_desktop_app_create_local_desktop_file); g_test_add_func (DOMAIN"/DesktopLess/Icon/ClassName", test_icon_class_name); g_test_add_func (DOMAIN"/DesktopLess/Icon/Exec", test_icon_exec_string); g_test_add_func (DOMAIN"/DesktopLess/Icon/Embedded", test_icon_embedded); g_test_add_func (DOMAIN"/DesktopLess/Icon/Priority", test_icon_priority); g_test_add_func (DOMAIN"/DesktopLess/Icon/Generic/Class", test_icon_generic_class); g_test_add_func (DOMAIN"/DesktopLess/Icon/Generic/Exec", test_icon_generic_exec); g_test_add_func (DOMAIN"/DesktopLess/MainChild", test_app_main_child); g_test_add_func (DOMAIN"/DesktopLess/MainChild/MatchesEmblems", test_app_main_child_matches_emblems); g_test_add_func (DOMAIN"/DesktopLess/MainChild/UpdatesEmblems", test_app_main_child_updates_emblems); g_test_add_func (DOMAIN"/DesktopLess/MainChild/MultipleChildren", test_app_main_child_multiple_children); g_test_add_func (DOMAIN"/DesktopLess/MainChild/NormalPriority", test_app_main_child_normal_priority); g_test_add_func (DOMAIN"/DesktopLess/MainChild/Removal", test_app_main_child_on_window_removal); g_test_add_func (DOMAIN"/DesktopLess/MainChild/ReplaceOnRemoval", test_app_main_child_on_window_replace_on_removal); g_test_add_func (DOMAIN"/DesktopLess/CreateLocalDesktopFile/InvalidExec", test_desktopless_app_create_local_desktop_file_invalid_exec); g_test_add_func (DOMAIN"/DesktopLess/CreateLocalDesktopFile/UsingClassInstance", test_desktopless_app_create_local_desktop_file_using_instance_class_basename); g_test_add_func (DOMAIN"/DesktopLess/CreateLocalDesktopFile/UsingClassName", test_desktopless_app_create_local_desktop_file_using_name_class_basename); g_test_add_func (DOMAIN"/DesktopLess/CreateLocalDesktopFile/UsingExec", test_desktopless_app_create_local_desktop_file_using_exec_basename); g_test_add_func (DOMAIN"/DesktopLess/CreateLocalDesktopFile/UsingTrimmedExec", test_desktopless_app_create_local_desktop_file_using_trimmed_exec_basename); g_test_add_func (DOMAIN"/DesktopLess/CreateLocalDesktopFile/WithWorkingDir", test_desktopless_app_create_local_desktop_file_with_working_dir); g_test_add_func (DOMAIN"/ManagesXid", test_manages_xid); g_test_add_func (DOMAIN"/GetWindow", test_get_window); g_test_add_func (DOMAIN"/Xids", test_get_xids); g_test_add_func (DOMAIN"/Events/Active", test_active); g_test_add_func (DOMAIN"/Events/Urgent", test_urgent); g_test_add_func (DOMAIN"/Events/UserVisible", test_user_visible); } ./tests/bamfdaemon/Makefile.am0000644000004100000410000000375014203512426016536 0ustar www-datawww-dataTESTDIR=$(shell realpath $(abs_top_srcdir)/tests) noinst_PROGRAMS = \ test-bamf bamf_test_extra_sources = \ $(top_srcdir)/src/bamf-daemon.c \ $(top_srcdir)/src/bamf-legacy-window.c \ $(top_srcdir)/src/bamf-legacy-window-test.c \ $(top_srcdir)/src/bamf-legacy-screen.c \ $(top_srcdir)/src/bamf-view.c \ $(top_srcdir)/src/bamf-control.c \ $(top_srcdir)/src/bamf-matcher.c \ $(top_srcdir)/src/bamf-application.c \ $(top_srcdir)/src/bamf-window.c \ $(top_srcdir)/src/bamf-tab.c \ $(top_srcdir)/src/bamf-xutils.c \ $(NULL) bamf_test_extra_headers = \ $(top_srcdir)/src/main.h \ $(top_srcdir)/src/bamf-daemon.h \ $(top_srcdir)/src/bamf-legacy-window.h \ $(top_srcdir)/src/bamf-legacy-window-test.h \ $(top_srcdir)/src/bamf-legacy-screen.h \ $(top_srcdir)/src/bamf-view.h \ $(top_srcdir)/src/bamf-control.h \ $(top_srcdir)/src/bamf-matcher.h \ $(top_srcdir)/src/bamf-window.h \ $(top_srcdir)/src/bamf-tab.h \ $(top_srcdir)/src/bamf-application.h \ $(top_srcdir)/src/bamf-xutils.h \ $(NULL) test_bamf_SOURCES = \ $(bamf_test_extra_sources) \ $(bamf_test_extra_headers) \ test-bamf.c \ test-view.c \ test-application.c \ test-window.c \ test-matcher.c test_bamf_CFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/lib \ -I$(top_builddir)/lib \ -DWNCK_I_KNOW_THIS_IS_UNSTABLE \ -DTESTDIR=\""$(TESTDIR)"\" \ $(COVERAGE_CFLAGS) \ $(GCC_FLAGS) \ $(GLIB_CFLAGS) \ $(GTK_CFLAGS) \ $(GTOP_CFLAGS) \ $(MAINTAINER_CFLAGS) \ $(SN_CFLAGS) \ $(WNCK_CFLAGS) \ $(X_CFLAGS) \ $(NULL) test_bamf_LDADD = \ $(top_builddir)/lib/libbamf-private/libbamf-private.la \ $(GLIB_LIBS) \ $(GTK_LIBS) \ $(GTOP_LIBS) \ $(SN_LIBS) \ $(WNCK_LIBS) \ $(X_LIBS) \ $(NULL) if EXPORT_ACTIONS_MENU test_bamf_LDADD += $(DBUSMENU_LIBS) test_bamf_CFLAGS += $(DBUSMENU_CFLAGS) test_bamf_CFLAGS += -DEXPORT_ACTIONS_MENU endif test_bamf_LDFLAGS = \ -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions \ $(COVERAGE_LDFLAGS) \ $(NULL) TEST_BINARY = test-bamf include $(top_srcdir)/tests/Makefile.am.gtests ./tests/bamfdaemon/test-matcher.c0000644000004100000410000014262614203512426017254 0ustar www-datawww-data/* * Copyright (C) 2009-2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Neil Jagdish Patel * Marco Trevisan (Treviño) * */ #include #include #include "bamf-matcher.h" #include "bamf-matcher-private.h" #include "bamf-legacy-screen-private.h" #include "bamf-legacy-window.h" #include "bamf-legacy-window-test.h" static GDBusConnection *gdbus_connection = NULL; #define DOMAIN "/Matcher" #define DATA_DIR TESTDIR "/data" #define TEST_BAMF_APP_DESKTOP DATA_DIR "/test-bamf-app.desktop" static void export_matcher_on_bus (BamfMatcher *matcher) { GError *error = NULL; g_return_if_fail (BAMF_IS_MATCHER (matcher)); g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (matcher), gdbus_connection, BAMF_DBUS_MATCHER_PATH, &error); g_assert (!error); g_clear_error (&error); } static void cleanup_matcher_tables (BamfMatcher *matcher) { g_return_if_fail (BAMF_IS_MATCHER (matcher)); g_hash_table_destroy (matcher->priv->desktop_file_table); g_hash_table_destroy (matcher->priv->desktop_id_table); g_hash_table_destroy (matcher->priv->desktop_class_table); g_list_free (matcher->priv->no_display_desktop); matcher->priv->desktop_file_table = g_hash_table_new_full ((GHashFunc) g_str_hash, (GEqualFunc) g_str_equal, (GDestroyNotify) g_free, NULL); matcher->priv->desktop_id_table = g_hash_table_new_full ((GHashFunc) g_str_hash, (GEqualFunc) g_str_equal, (GDestroyNotify) g_free, NULL); matcher->priv->desktop_class_table = g_hash_table_new_full ((GHashFunc) g_str_hash, (GEqualFunc) g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_free); matcher->priv->no_display_desktop = NULL; } static BamfWindow * find_window_in_matcher (BamfMatcher *matcher, BamfLegacyWindow *legacy) { GList *l; BamfWindow *found_window = NULL; for (l = matcher->priv->views; l; l = l->next) { if (!BAMF_IS_WINDOW (l->data)) continue; if (bamf_window_get_window (BAMF_WINDOW (l->data)) == legacy) { g_assert (!found_window); found_window = l->data; } } return found_window; } static BamfWindow * find_window_in_app (BamfApplication *app, BamfLegacyWindow *legacy) { GList *l; BamfWindow *found_window = NULL; g_return_val_if_fail (BAMF_IS_APPLICATION (app), NULL); for (l = bamf_view_get_children (BAMF_VIEW (app)); l; l = l->next) { if (!BAMF_IS_WINDOW (l->data)) continue; if (bamf_window_get_window (BAMF_WINDOW (l->data)) == legacy) { g_assert (!found_window); found_window = l->data; } } return found_window; } static void test_allocation (void) { BamfMatcher *matcher; /* Check it allocates */ matcher = bamf_matcher_get_default (); g_assert (BAMF_IS_MATCHER (matcher)); g_object_unref (matcher); } static void test_load_desktop_file (void) { BamfMatcher *matcher = bamf_matcher_get_default (); BamfMatcherPrivate *priv = matcher->priv; cleanup_matcher_tables (matcher); bamf_matcher_load_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); GList *l = g_hash_table_lookup (priv->desktop_file_table, "test-bamf-app"); g_assert (l); g_assert_cmpstr (l->data, ==, TEST_BAMF_APP_DESKTOP); l = g_hash_table_lookup (priv->desktop_id_table, "test-bamf-app"); g_assert (l); g_assert_cmpstr (l->data, ==, TEST_BAMF_APP_DESKTOP); const char *desktop = g_hash_table_lookup (priv->desktop_class_table, TEST_BAMF_APP_DESKTOP); g_assert_cmpstr (desktop, ==, "test_bamf_app"); g_object_unref (matcher); } static void test_load_desktop_file_autostart (void) { BamfMatcher *matcher = bamf_matcher_get_default (); BamfMatcherPrivate *priv = matcher->priv; gchar *file = g_build_filename (g_get_user_config_dir(), "autostart", "foo-app.desktop", NULL); cleanup_matcher_tables (matcher); bamf_matcher_load_desktop_file (matcher, file); g_assert (!g_hash_table_lookup (priv->desktop_id_table, "foo-app")); g_free (file); g_object_unref (matcher); } static void test_load_desktop_file_no_display_has_lower_prio_same_id (void) { BamfMatcher *matcher = bamf_matcher_get_default (); BamfMatcherPrivate *priv = matcher->priv; cleanup_matcher_tables (matcher); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/no-display/test-bamf-app.desktop"); bamf_matcher_load_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); GList *l = g_hash_table_lookup (priv->desktop_file_table, "test-bamf-app"); g_assert (l); g_assert_cmpstr (l->data, ==, TEST_BAMF_APP_DESKTOP); g_assert (l->next); g_assert_cmpstr (l->next->data, ==, DATA_DIR"/no-display/test-bamf-app.desktop"); l = g_hash_table_lookup (priv->desktop_id_table, "test-bamf-app"); g_assert (l); g_assert_cmpstr (l->data, ==, TEST_BAMF_APP_DESKTOP); g_assert (l->next); g_assert_cmpstr (l->next->data, ==, DATA_DIR"/no-display/test-bamf-app.desktop"); g_object_unref (matcher); } static void test_load_desktop_file_no_display_has_lower_prio_different_id (void) { BamfMatcher *matcher = bamf_matcher_get_default (); BamfMatcherPrivate *priv = matcher->priv; cleanup_matcher_tables (matcher); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/test-bamf-app-no-display.desktop"); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/test-bamf-app-display.desktop"); GList *l = g_hash_table_lookup (priv->desktop_file_table, "test-bamf-app"); g_assert (l); g_assert_cmpstr (l->data, ==, DATA_DIR"/test-bamf-app-display.desktop"); g_assert (l->next); g_assert_cmpstr (l->next->data, ==, DATA_DIR"/test-bamf-app-no-display.desktop"); g_object_unref (matcher); } static void test_register_desktop_for_pid (void) { BamfMatcher *matcher = bamf_matcher_get_default (); BamfMatcherPrivate *priv = matcher->priv; guint pid = g_random_int (); bamf_matcher_register_desktop_file_for_pid (matcher, TEST_BAMF_APP_DESKTOP, pid); char *desktop = g_hash_table_lookup (priv->registered_pids, GUINT_TO_POINTER (pid)); g_assert_cmpstr (desktop, ==, TEST_BAMF_APP_DESKTOP); g_object_unref (matcher); } static void test_register_desktop_for_pid_big_number (void) { BamfMatcher *matcher = bamf_matcher_get_default (); BamfMatcherPrivate *priv = matcher->priv; bamf_matcher_register_desktop_file_for_pid (matcher, TEST_BAMF_APP_DESKTOP, G_MAXINT64); char *desktop = g_hash_table_lookup (priv->registered_pids, GUINT_TO_POINTER (G_MAXINT64)); g_assert_cmpstr (desktop, ==, TEST_BAMF_APP_DESKTOP); g_object_unref (matcher); } static void test_register_desktop_for_pid_autostart (void) { BamfMatcher *matcher = bamf_matcher_get_default (); BamfMatcherPrivate *priv = matcher->priv; guint pid = g_random_int (); gchar *desktop = g_build_filename (g_get_user_config_dir(), "autostart", "foo-app.desktop", NULL); bamf_matcher_register_desktop_file_for_pid (matcher, desktop, pid); g_free (desktop); desktop = g_hash_table_lookup (priv->registered_pids, GUINT_TO_POINTER (pid)); g_assert_cmpstr (desktop, ==, NULL); g_object_unref (matcher); } static void test_register_desktop_for_pid_display (void) { BamfMatcher *matcher = bamf_matcher_get_default (); BamfMatcherPrivate *priv = matcher->priv; guint pid = g_random_int (); const gchar *desktop = DATA_DIR"/test-bamf-app-display.desktop"; cleanup_matcher_tables (matcher); bamf_matcher_load_desktop_file (matcher, desktop); bamf_matcher_register_desktop_file_for_pid (matcher, desktop, pid); desktop = g_hash_table_lookup (priv->registered_pids, GUINT_TO_POINTER (pid)); g_assert_cmpstr (desktop, ==, DATA_DIR"/test-bamf-app-display.desktop"); g_object_unref (matcher); } static void test_register_desktop_for_pid_nodisplay (void) { BamfMatcher *matcher = bamf_matcher_get_default (); BamfMatcherPrivate *priv = matcher->priv; guint pid = g_random_int (); const gchar *desktop = DATA_DIR"/test-bamf-app-no-display.desktop"; cleanup_matcher_tables (matcher); bamf_matcher_load_desktop_file (matcher, desktop); bamf_matcher_register_desktop_file_for_pid (matcher, desktop, pid); desktop = g_hash_table_lookup (priv->registered_pids, GUINT_TO_POINTER (pid)); g_assert_cmpstr (desktop, ==, NULL); g_object_unref (matcher); } static void test_open_windows (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindow *window; BamfLegacyWindowTest *test_win; guint xid; const int window_count = 500; screen = bamf_legacy_screen_get_default(); matcher = bamf_matcher_get_default (); cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) { gchar *name = g_strdup_printf ("Test Window %u", xid); gchar *class = g_strdup_printf ("test-class-%u", xid); gchar *exec = g_strdup_printf ("test-class-%u", xid); test_win = bamf_legacy_window_test_new (xid, name, class, exec); window = BAMF_LEGACY_WINDOW (test_win); _bamf_legacy_screen_open_test_window (screen, test_win); g_assert (g_list_find (bamf_legacy_screen_get_windows (screen), test_win)); g_assert (find_window_in_matcher (matcher, window)); g_assert (bamf_matcher_get_application_by_xid (matcher, xid)); _bamf_legacy_screen_close_test_window (screen, test_win); g_assert (!g_list_find (bamf_legacy_screen_get_windows (screen), test_win)); g_assert (!find_window_in_matcher (matcher, window)); g_assert (!bamf_matcher_get_application_by_xid (matcher, xid)); g_free (name); g_free (class); g_free (exec); } g_object_unref (matcher); g_object_unref (screen); } static void test_match_desktopless_application (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindow *window; BamfLegacyWindowTest *test_win; BamfApplication *app; GList *test_windows = NULL, *l, *app_children; guint xid; const int window_count = 5; screen = bamf_legacy_screen_get_default(); matcher = bamf_matcher_get_default (); const char *exec = "test-bamf-app"; const char *class = "test-bamf-app"; cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) { gchar *name = g_strdup_printf ("Test Window %u", xid); test_win = bamf_legacy_window_test_new (xid, name, class, exec); window = BAMF_LEGACY_WINDOW (test_win); test_windows = g_list_prepend (test_windows, window); _bamf_legacy_screen_open_test_window (screen, test_win); g_free (name); } app = bamf_matcher_get_application_by_xid (matcher, G_MAXUINT); g_assert (app); app_children = bamf_view_get_children (BAMF_VIEW (app)); g_assert_cmpuint (g_list_length (app_children), ==, window_count); for (l = test_windows; l; l = l->next) { g_assert (find_window_in_app (app, BAMF_LEGACY_WINDOW (l->data))); } g_list_free (test_windows); g_object_unref (matcher); g_object_unref (screen); } static void test_match_desktop_application (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindow *window; BamfLegacyWindowTest *test_win; BamfApplication *app; GList *test_windows = NULL, *l, *app_children; guint xid; const int window_count = 5; screen = bamf_legacy_screen_get_default(); matcher = bamf_matcher_get_default (); const char *exec = "testbamfapp"; const char *class = "test_bamf_app"; cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); bamf_matcher_load_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) { gchar *name = g_strdup_printf ("Test Window %u", xid); test_win = bamf_legacy_window_test_new (xid, name, class, exec); window = BAMF_LEGACY_WINDOW (test_win); test_windows = g_list_prepend (test_windows, window); _bamf_legacy_screen_open_test_window (screen, test_win); g_free (name); } app = bamf_matcher_get_application_by_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); g_assert (app); g_assert (bamf_matcher_get_application_by_xid (matcher, G_MAXUINT) == app); app_children = bamf_view_get_children (BAMF_VIEW (app)); g_assert_cmpuint (g_list_length (app_children), ==, window_count); for (l = test_windows; l; l = l->next) { g_assert (find_window_in_app (app, BAMF_LEGACY_WINDOW (l->data))); } g_list_free (test_windows); g_object_unref (matcher); g_object_unref (screen); } static void test_new_desktop_matches_unmatched_windows (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindowTest *test_win; BamfApplication *app; GList *app_children; guint xid = 0; const int window_count = 5; screen = bamf_legacy_screen_get_default(); matcher = bamf_matcher_get_default (); const char *exec = "testbamfapp"; const char *class = "test_bamf_app"; cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, TEST_BAMF_APP_DESKTOP)); for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) { gchar *name = g_strdup_printf ("Test Window %u", xid); test_win = bamf_legacy_window_test_new (xid, name, class, exec); _bamf_legacy_screen_open_test_window (screen, test_win); g_free (name); } bamf_matcher_load_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); app = bamf_matcher_get_application_by_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); g_assert (app); app_children = bamf_view_get_children (BAMF_VIEW (app)); g_assert_cmpuint (g_list_length (app_children), ==, window_count); for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) { g_assert (bamf_matcher_get_application_by_xid (matcher, xid) == app); } g_object_unref (matcher); g_object_unref (screen); } static void test_match_libreoffice_windows (void) { BamfMatcher *matcher; BamfWindow *window; BamfLegacyScreen *screen; BamfLegacyWindowTest *test_win; BamfApplication *app; screen = bamf_legacy_screen_get_default (); matcher = bamf_matcher_get_default (); guint xid = g_random_int (); const char *exec = "soffice.bin"; const char *class_instance = "VCLSalFrame.DocumentWindow"; cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-startcenter.desktop"); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-base.desktop"); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-calc.desktop"); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-draw.desktop"); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-impress.desktop"); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-math.desktop"); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-writer.desktop"); test_win = bamf_legacy_window_test_new (xid, "LibreOffice", "libreoffice-startcenter", exec); bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-startcenter", class_instance); _bamf_legacy_screen_open_test_window (screen, test_win); app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-startcenter.desktop"); g_assert (find_window_in_app (app, BAMF_LEGACY_WINDOW (test_win))); bamf_legacy_window_test_set_name (test_win, "FooDoc.odb - LibreOffice Base"); bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-base", class_instance); g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-startcenter.desktop")); app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-base.desktop"); g_assert (app); g_assert_cmpuint (g_list_length (bamf_view_get_children (BAMF_VIEW (app))), ==, 1); window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); g_assert (bamf_window_get_window (window) == BAMF_LEGACY_WINDOW (test_win)); bamf_legacy_window_test_set_name (test_win, "FooDoc.ods - LibreOffice Calc"); bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-calc", class_instance); g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-base.desktop")); app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-calc.desktop"); g_assert (app); g_assert_cmpuint (g_list_length (bamf_view_get_children (BAMF_VIEW (app))), ==, 1); window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); g_assert (bamf_window_get_window (window) == BAMF_LEGACY_WINDOW (test_win)); bamf_legacy_window_test_set_name (test_win, "FooDoc.odg - LibreOffice Draw"); bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-draw", class_instance); g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-calc.desktop")); app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-draw.desktop"); g_assert (app); g_assert_cmpuint (g_list_length (bamf_view_get_children (BAMF_VIEW (app))), ==, 1); window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); g_assert (bamf_window_get_window (window) == BAMF_LEGACY_WINDOW (test_win)); bamf_legacy_window_test_set_name (test_win, "FooDoc.odp - LibreOffice Impress"); bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-impress", class_instance); g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-draw.desktop")); app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-impress.desktop"); g_assert (app); g_assert_cmpuint (g_list_length (bamf_view_get_children (BAMF_VIEW (app))), ==, 1); window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); g_assert (bamf_window_get_window (window) == BAMF_LEGACY_WINDOW (test_win)); bamf_legacy_window_test_set_name (test_win, "FooDoc.odf - LibreOffice Math"); bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-math", class_instance); g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-impress.desktop")); app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-math.desktop"); g_assert (app); g_assert_cmpuint (g_list_length (bamf_view_get_children (BAMF_VIEW (app))), ==, 1); window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); g_assert (bamf_window_get_window (window) == BAMF_LEGACY_WINDOW (test_win)); bamf_legacy_window_test_set_name (test_win, "FooDoc.odt - LibreOffice Writer"); bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-writer", class_instance); g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-math.desktop")); app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-writer.desktop"); g_assert (app); g_assert_cmpuint (g_list_length (bamf_view_get_children (BAMF_VIEW (app))), ==, 1); window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); g_assert (bamf_window_get_window (window) == BAMF_LEGACY_WINDOW (test_win)); xid = g_random_int (); test_win = bamf_legacy_window_test_new (xid, "BarDoc.odt - LibreOffice Writer", "libreoffice-writer", exec); bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-writer", class_instance); _bamf_legacy_screen_open_test_window (screen, test_win); g_assert_cmpuint (g_list_length (bamf_view_get_children (BAMF_VIEW (app))), ==, 2); xid = g_random_int (); test_win = bamf_legacy_window_test_new (xid, "BarDoc.ods - LibreOffice Calc", "libreoffice-calc", exec); bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-calc", class_instance); _bamf_legacy_screen_open_test_window (screen, test_win); g_assert (bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-calc.desktop")); g_object_unref (matcher); g_object_unref (screen); } static void test_match_unity_control_center_panels (void) { BamfMatcher *matcher; BamfWindow *window; BamfLegacyScreen *screen; BamfLegacyWindowTest *test_win; BamfApplication *app; char *hint; screen = bamf_legacy_screen_get_default (); matcher = bamf_matcher_get_default (); guint xid = g_random_int (); const char *exec = "unity-control-center"; const char *class_name = "Unity-control-center"; const char *class_instance = "unity-control-center"; cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/unity-control-center.desktop"); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/unity-display-panel.desktop"); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/unity-mouse-panel.desktop"); test_win = bamf_legacy_window_test_new (xid, "System Settings", NULL, exec); bamf_legacy_window_test_set_wmclass (test_win, class_name, class_instance); bamf_legacy_window_test_set_role (test_win, NULL); _bamf_legacy_screen_open_test_window (screen, test_win); hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _BAMF_DESKTOP_FILE); g_assert_cmpstr (hint, ==, DATA_DIR"/unity-control-center.desktop"); g_free (hint); app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/unity-control-center.desktop"); g_assert (find_window_in_app (app, BAMF_LEGACY_WINDOW (test_win))); bamf_legacy_window_test_set_name (test_win, "Displays"); bamf_legacy_window_test_set_role (test_win, "display"); g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/unity-control-center.desktop")); app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/unity-display-panel.desktop"); g_assert (app); window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); test_win = BAMF_LEGACY_WINDOW_TEST (bamf_window_get_window (window)); hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _BAMF_DESKTOP_FILE); g_assert_cmpstr (hint, ==, DATA_DIR"/unity-display-panel.desktop"); g_free (hint); bamf_legacy_window_test_set_name (test_win, "Mouse and Touchpad"); bamf_legacy_window_test_set_role (test_win, "mouse"); g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/unity-display-panel.desktop")); app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/unity-mouse-panel.desktop"); g_assert (app); window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); test_win = BAMF_LEGACY_WINDOW_TEST (bamf_window_get_window (window)); hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _BAMF_DESKTOP_FILE); g_assert_cmpstr (hint, ==, DATA_DIR"/unity-mouse-panel.desktop"); g_free (hint); bamf_legacy_window_test_set_name (test_win, "Invalid Panel"); bamf_legacy_window_test_set_role (test_win, "invalid-role"); g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/unity-mouse-panel.desktop")); app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/unity-control-center.desktop"); g_assert (app); window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); test_win = BAMF_LEGACY_WINDOW_TEST (bamf_window_get_window (window)); hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _BAMF_DESKTOP_FILE); g_assert_cmpstr (hint, ==, DATA_DIR"/unity-control-center.desktop"); g_free (hint); g_object_unref (matcher); g_object_unref (screen); } static void test_match_javaws_windows (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindowTest *test_win; BamfApplication *app1, *app2, *app3; GList *app_children; screen = bamf_legacy_screen_get_default (); matcher = bamf_matcher_get_default (); const char *exec_prefix = "/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws " \ "-Xbootclasspath/a:/usr/share/icedtea-web/netx.jar " \ "-Xms8m -Djava.security.manager " \ "-Djava.security.policy=/etc/icedtea-web/javaws.policy " \ "-classpath /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/rt.jar " \ "-Dicedtea-web.bin.name=javaws " \ "-Dicedtea-web.bin.location=/usr/bin/javaws "\ "net.sourceforge.jnlp.runtime.Boot"; const char *class_name = "net-sourceforge-jnlp-runtime-Boot"; const char *class_instance = "sun-awt-X11-XFramePeer"; cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); guint xid = g_random_int (); char *exec = g_strconcat (exec_prefix, " Notepad.jnlp", NULL); test_win = bamf_legacy_window_test_new (xid, "Notepad", NULL, exec); bamf_legacy_window_test_set_wmclass (test_win, class_name, class_instance); _bamf_legacy_screen_open_test_window (screen, test_win); g_free (exec); app1 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (BAMF_IS_APPLICATION (app1)); app_children = bamf_view_get_children (BAMF_VIEW (app1)); g_assert_cmpuint (g_list_length (app_children), ==, 1); g_assert (find_window_in_app (app1, BAMF_LEGACY_WINDOW (test_win))); xid = g_random_int (); exec = g_strconcat (exec_prefix, " Draw.jnlp", NULL); test_win = bamf_legacy_window_test_new (xid, "Draw", NULL, exec); bamf_legacy_window_test_set_wmclass (test_win, class_name, class_instance); _bamf_legacy_screen_open_test_window (screen, test_win); g_free (exec); app2 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (BAMF_IS_APPLICATION (app2)); g_assert (app1 != app2); app_children = bamf_view_get_children (BAMF_VIEW (app2)); g_assert_cmpuint (g_list_length (app_children), ==, 1); g_assert (find_window_in_app (app2, BAMF_LEGACY_WINDOW (test_win))); xid = g_random_int (); exec = g_strconcat (exec_prefix, " Notepad.jnlp", NULL); test_win = bamf_legacy_window_test_new (xid, "Notepad Subwin", NULL, exec); bamf_legacy_window_test_set_wmclass (test_win, class_name, class_instance); _bamf_legacy_screen_open_test_window (screen, test_win); g_free (exec); app3 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (app3 == app1); g_assert (BAMF_IS_APPLICATION (app3)); app_children = bamf_view_get_children (BAMF_VIEW (app3)); g_assert_cmpuint (g_list_length (app_children), ==, 2); g_assert (find_window_in_app (app3, BAMF_LEGACY_WINDOW (test_win))); g_object_unref (matcher); g_object_unref (screen); } static void test_match_javaws_windows_hint_ignored (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindowTest *test_win; BamfApplication *app; screen = bamf_legacy_screen_get_default (); matcher = bamf_matcher_get_default (); const char *exec_prefix = "/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws " \ "-Xbootclasspath/a:/usr/share/icedtea-web/netx.jar " \ "-Xms8m -Djava.security.manager " \ "-Djava.security.policy=/etc/icedtea-web/javaws.policy " \ "-classpath /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/rt.jar " \ "-Dicedtea-web.bin.name=javaws " \ "-Dicedtea-web.bin.location=/usr/bin/javaws "\ "net.sourceforge.jnlp.runtime.Boot "; const char *class_name = "net-sourceforge-jnlp-runtime-Boot"; const char *class_instance = "sun-awt-X11-XFramePeer"; cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); guint xid = g_random_int (); guint pid = g_random_int (); char *exec = g_strconcat (exec_prefix, "Notepad.jnlp", NULL); test_win = bamf_legacy_window_test_new (xid, "Notepad", NULL, exec); bamf_legacy_window_test_set_wmclass (test_win, class_name, class_instance); test_win->pid = pid; _bamf_legacy_screen_open_test_window (screen, test_win); g_free (exec); bamf_matcher_register_desktop_file_for_pid (matcher, DATA_DIR"/icedtea-netx-javaws.desktop", pid); char *hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _BAMF_DESKTOP_FILE); g_assert (hint == NULL); app = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (BAMF_IS_APPLICATION (app)); g_assert (bamf_application_get_desktop_file (app) == NULL); g_object_unref (matcher); g_object_unref (screen); } static void test_match_javaws_windows_no_desktop_match (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindowTest *test_win; BamfApplication *app; screen = bamf_legacy_screen_get_default (); matcher = bamf_matcher_get_default (); const char *exec_prefix = "/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws " \ "-Xbootclasspath/a:/usr/share/icedtea-web/netx.jar " \ "-Xms8m -Djava.security.manager " \ "-Djava.security.policy=/etc/icedtea-web/javaws.policy " \ "-classpath /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/rt.jar " \ "-Dicedtea-web.bin.name=javaws " \ "-Dicedtea-web.bin.location=/usr/bin/javaws "\ "net.sourceforge.jnlp.runtime.Boot "; const char *class_name = "net-sourceforge-jnlp-runtime-Boot"; const char *class_instance = "sun-awt-X11-XFramePeer"; cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/icedtea-netx-javaws.desktop"); guint xid = g_random_int (); char *exec = g_strconcat (exec_prefix, "Notepad.jnlp", NULL); test_win = bamf_legacy_window_test_new (xid, "Notepad", NULL, exec); bamf_legacy_window_test_set_wmclass (test_win, class_name, class_instance); _bamf_legacy_screen_open_test_window (screen, test_win); g_free (exec); app = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (BAMF_IS_APPLICATION (app)); g_assert (bamf_application_get_desktop_file (app) == NULL); g_object_unref (matcher); g_object_unref (screen); } static void test_match_qml_app_no_desktop (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindowTest *test_win; BamfApplication *app1, *app2, *app3; screen = bamf_legacy_screen_get_default (); matcher = bamf_matcher_get_default (); cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); guint xid = g_random_int (); test_win = bamf_legacy_window_test_new (xid, "QmlApp1", NULL, "qmlscene qmlapp1.qml"); bamf_legacy_window_test_set_wmclass (test_win, NULL, NULL); _bamf_legacy_screen_open_test_window (screen, test_win); app1 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (BAMF_IS_APPLICATION (app1)); xid = g_random_int (); test_win = bamf_legacy_window_test_new (xid, "QmlApp2", NULL, "qmlscene qmlapp2.qml"); bamf_legacy_window_test_set_wmclass (test_win, NULL, NULL); _bamf_legacy_screen_open_test_window (screen, test_win); app2 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (BAMF_IS_APPLICATION (app2)); g_assert (app1 != app2); xid = g_random_int (); test_win = bamf_legacy_window_test_new (xid, "QmlApp2", NULL, "qmlscene qmlapp2.qml"); bamf_legacy_window_test_set_wmclass (test_win, NULL, NULL); _bamf_legacy_screen_open_test_window (screen, test_win); app3 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (BAMF_IS_APPLICATION (app3)); g_assert (app2 == app3); g_object_unref (matcher); g_object_unref (screen); } static void test_match_qml_app_desktop (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindowTest *test_win; BamfApplication *app1, *app2, *app3; screen = bamf_legacy_screen_get_default (); matcher = bamf_matcher_get_default (); cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); bamf_matcher_load_desktop_file (matcher, DATA_DIR"/bamf-qml-app.desktop"); guint xid = g_random_int (); test_win = bamf_legacy_window_test_new (xid, "QmlAppWin1", NULL, "/path/qmlscene bamf_qml_app.qml"); bamf_legacy_window_test_set_wmclass (test_win, NULL, NULL); _bamf_legacy_screen_open_test_window (screen, test_win); app1 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (BAMF_IS_APPLICATION (app1)); g_assert_cmpstr (bamf_application_get_desktop_file (app1), ==, DATA_DIR"/bamf-qml-app.desktop"); xid = g_random_int (); test_win = bamf_legacy_window_test_new (xid, "QmlAppWin1", NULL, "qmlscene files/foo/bamf_qml_app.qml"); bamf_legacy_window_test_set_wmclass (test_win, NULL, NULL); _bamf_legacy_screen_open_test_window (screen, test_win); app2 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (BAMF_IS_APPLICATION (app2)); g_assert (app1 == app2); xid = g_random_int (); test_win = bamf_legacy_window_test_new (xid, "QmlApp2", NULL, "qmlscene qmlapp2.qml"); bamf_legacy_window_test_set_wmclass (test_win, NULL, NULL); _bamf_legacy_screen_open_test_window (screen, test_win); app3 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (BAMF_IS_APPLICATION (app3)); g_assert (app2 != app3); g_object_unref (matcher); g_object_unref (screen); } static void test_match_desktop_file_hint_exec (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindowTest *test_win; BamfApplication *app1, *app2, *app3; screen = bamf_legacy_screen_get_default (); matcher = bamf_matcher_get_default (); cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); bamf_matcher_load_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); guint xid = g_random_int (); const gchar *exec = "/path/qmlscene --desktop_file_hint "TEST_BAMF_APP_DESKTOP" test-qml-app1.qml"; test_win = bamf_legacy_window_test_new (xid, "QmlAppWin1", NULL, exec); _bamf_legacy_screen_open_test_window (screen, test_win); app1 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert_cmpstr (bamf_application_get_desktop_file (app1), ==, TEST_BAMF_APP_DESKTOP); _bamf_legacy_screen_close_test_window (screen, test_win); xid = g_random_int (); exec = "/path/qmlscene test-qml-app2.qml --desktop_file_hint "TEST_BAMF_APP_DESKTOP; test_win = bamf_legacy_window_test_new (xid, "QmlAppWin2", NULL, exec); bamf_legacy_window_test_set_wmclass (test_win, NULL, NULL); _bamf_legacy_screen_open_test_window (screen, test_win); app2 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert_cmpstr (bamf_application_get_desktop_file (app2), ==, TEST_BAMF_APP_DESKTOP); _bamf_legacy_screen_close_test_window (screen, test_win); xid = g_random_int (); exec = "test-bamf-app --desktop_file_hint "TEST_BAMF_APP_DESKTOP; test_win = bamf_legacy_window_test_new (xid, "AnyAppWin1", NULL, exec); bamf_legacy_window_test_set_wmclass (test_win, NULL, NULL); _bamf_legacy_screen_open_test_window (screen, test_win); app3 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert_cmpstr (bamf_application_get_desktop_file (app3), ==, TEST_BAMF_APP_DESKTOP); g_object_unref (matcher); g_object_unref (screen); } static void test_match_desktop_file_hint_exec_invalid (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindowTest *test_win; BamfApplication *app1, *app2, *app3; screen = bamf_legacy_screen_get_default (); matcher = bamf_matcher_get_default (); cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); bamf_matcher_load_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); guint xid = g_random_int (); const gchar *exec = "/path/qmlscene --desktop_file_hint invalid-file.desktop test-qml-app1.qml"; test_win = bamf_legacy_window_test_new (xid, "QmlAppWin1", NULL, exec); _bamf_legacy_screen_open_test_window (screen, test_win); app1 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert_cmpstr (bamf_application_get_desktop_file (app1), ==, NULL); xid = g_random_int (); exec = "/path/qmlscene test-qml-app2.qml --desktop_file_hint "TEST_BAMF_APP_DESKTOP"s"; test_win = bamf_legacy_window_test_new (xid, "QmlAppWin2", NULL, exec); bamf_legacy_window_test_set_wmclass (test_win, NULL, NULL); _bamf_legacy_screen_open_test_window (screen, test_win); app2 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert_cmpstr (bamf_application_get_desktop_file (app2), ==, NULL); g_assert (app2 != app1); _bamf_legacy_screen_close_test_window (screen, test_win); xid = g_random_int (); exec = "test-bamf-app --desktop_file_hint invalid-file"; test_win = bamf_legacy_window_test_new (xid, "AnyAppWin1", NULL, exec); bamf_legacy_window_test_set_wmclass (test_win, NULL, NULL); _bamf_legacy_screen_open_test_window (screen, test_win); app3 = bamf_matcher_get_application_by_xid (matcher, xid); g_assert_cmpstr (bamf_application_get_desktop_file (app3), ==, TEST_BAMF_APP_DESKTOP); g_assert (app3 != app1); g_assert (app3 != app2); g_object_unref (matcher); g_object_unref (screen); } static void test_match_transient_windows (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindowTest *main_window; BamfLegacyWindowTest *child_window; BamfApplication *main_app, *child_app; GList *app_children; guint32 xid; screen = bamf_legacy_screen_get_default(); matcher = bamf_matcher_get_default (); const char *exec = "test-bamf-app"; const char *class = "test-bamf-app"; cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); xid = g_random_int (); main_window = bamf_legacy_window_test_new (xid, "Main Window", class, exec); _bamf_legacy_screen_open_test_window (screen, main_window); main_app = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (main_app); app_children = bamf_view_get_children (BAMF_VIEW (main_app)); g_assert_cmpuint (g_list_length (app_children), ==, 1); g_assert (find_window_in_app (main_app, BAMF_LEGACY_WINDOW (main_window))); xid = g_random_int (); child_window = bamf_legacy_window_test_new (xid, "Child Window", NULL, NULL); child_window->window_type = BAMF_WINDOW_DIALOG; child_window->transient_window = BAMF_LEGACY_WINDOW (main_window); _bamf_legacy_screen_open_test_window (screen, child_window); child_app = bamf_matcher_get_application_by_xid (matcher, xid); g_assert (child_app == main_app); app_children = bamf_view_get_children (BAMF_VIEW (main_app)); g_assert_cmpuint (g_list_length (app_children), ==, 2); g_assert (find_window_in_app (main_app, BAMF_LEGACY_WINDOW (child_window))); g_object_unref (matcher); g_object_unref (screen); } static void test_trim_exec_string (void) { BamfMatcher *matcher; char *trimmed; matcher = bamf_matcher_get_default (); // Bad prefixes trimmed = bamf_matcher_get_trimmed_exec (matcher, "gksudo bad-prefix-bin"); g_assert_cmpstr (trimmed, ==, "bad-prefix-bin"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "gksu python very-bad-prefix-script.py"); g_assert_cmpstr (trimmed, ==, "very-bad-prefix-script"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "sudo --opt val=X /usr/bin/bad-prefix-bin"); g_assert_cmpstr (trimmed, ==, "bad-prefix-bin"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "python2.7 /home/foo/bad-prefix-script.py"); g_assert_cmpstr (trimmed, ==, "bad-prefix-script"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "/usr/bin/python3 /usr/bin/gnome-language-selector"); g_assert_cmpstr (trimmed, ==, "gnome-language-selector"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "/usr/bin/python3.1"); g_assert_cmpstr (trimmed, ==, "python3.1"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "/usr/bin/python %u --option val=/path"); g_assert_cmpstr (trimmed, ==, "python"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "/usr/bin/mono /usr/share/bar/Foo.exe"); g_assert_cmpstr (trimmed, ==, "foo.exe"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "/usr/bin/mono %u --option val=/path"); g_assert_cmpstr (trimmed, ==, "mono"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "/usr/bin/cli /usr/share/foo/Bar.exe"); g_assert_cmpstr (trimmed, ==, "bar.exe"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "/usr/bin/cli %u --option val=/path"); g_assert_cmpstr (trimmed, ==, "cli"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "sh -c \"binary --option --value %U || exec binary\""); g_assert_cmpstr (trimmed, ==, "binary"); g_free (trimmed); // Good prefixes trimmed = bamf_matcher_get_trimmed_exec (matcher, "/usr/bin/libreoffice --writer %U"); g_assert_cmpstr (trimmed, ==, "libreoffice --writer"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "/usr/bin/unity-control-center"); g_assert_cmpstr (trimmed, ==, "unity-control-center"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "unity-control-center foo-panel"); g_assert_cmpstr (trimmed, ==, "unity-control-center foo-panel"); g_free (trimmed); // Other exec strings trimmed = bamf_matcher_get_trimmed_exec (matcher, "env FOOVAR=\"bar\" myprog"); g_assert_cmpstr (trimmed, ==, "myprog"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "/opt/path/bin/myprog --option %U --foo=daa"); g_assert_cmpstr (trimmed, ==, "myprog"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "/usr/bin/qmlscene my-app.qml"); g_assert_cmpstr (trimmed, ==, "my-app"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "qmlscene /home/user/new-app.qml"); g_assert_cmpstr (trimmed, ==, "new-app"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "qmlscene $var /home/user/var-new-app.qml"); g_assert_cmpstr (trimmed, ==, "var-new-app"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "qmlscene --option -foo /home/user/opt-app.qml"); g_assert_cmpstr (trimmed, ==, "opt-app"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "qmlscene --desktop_file_hint deskapp.desktop desktop-app1.qml"); g_assert_cmpstr (trimmed, ==, "desktop-app1"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "qmlscene desktop-app2.qml --desktop_file_hint deskapp.desktop"); g_assert_cmpstr (trimmed, ==, "desktop-app2"); g_free (trimmed); trimmed = bamf_matcher_get_trimmed_exec (matcher, "qmlscene desktop-app3.qml --desktop_file_hint"); g_assert_cmpstr (trimmed, ==, "desktop-app3"); g_free (trimmed); const char *exec = "/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java " \ "-Xbootclasspath/a:/usr/share/icedtea-web/netx.jar " \ "-Xms8m -Djava.security.manager " \ "-Djava.security.policy=/etc/icedtea-web/javaws.policy " \ "-classpath /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/rt.jar " \ "-Dicedtea-web.bin.name=javaws " \ "-Dicedtea-web.bin.location=/usr/bin/javaws "\ "net.sourceforge.jnlp.runtime.Boot Notepad.jnlp"; trimmed = bamf_matcher_get_trimmed_exec (matcher, exec); g_assert_cmpstr (trimmed, ==, "notepad.jnlp"); g_free (trimmed); exec = "/usr/lib/jvm/java-7-oracle/jre/bin/java " \ "-classpath /usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar " \ "-Djava.security.policy=file:/usr/lib/jvm/java-7-oracle/jre/lib/security/javaws.policy " \ "-DtrustProxy=true -Xverify:remote " \ "-Djnlpx.home=/usr/lib/jvm/java-7-oracle/jre/bin " \ "-Djnlpx.remove=true -Dsun.awt.warmup=true " \ "-Xbootclasspath/a:/usr/lib/jvm/java-7-oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-7-oracle/jre/lib/plugin.jar " \ "-Xms12m -Xmx384m -Djnlpx.jvm=/usr/lib/jvm/java-7-oracle/jre/bin/java " \ "com.sun.javaws.Main Notepad.jnlp"; trimmed = bamf_matcher_get_trimmed_exec (matcher, exec); g_assert_cmpstr (trimmed, ==, "notepad.jnlp"); g_free (trimmed); g_object_unref (matcher); } static void test_autostart_desktop_file_user (void) { gchar *file = g_build_filename (g_get_user_config_dir(), "autostart", "foo-app.desktop", NULL); g_assert (is_autostart_desktop_file (file)); g_free (file); file = g_build_filename (g_get_user_config_dir(), "foo-app.desktop", NULL); g_assert (!is_autostart_desktop_file (file)); g_free (file); } static void test_autostart_desktop_file_system (void) { const gchar * const * data_dirs = g_get_system_config_dirs (); gint i; for (i = 0; data_dirs[i]; ++i) { gchar *file = g_build_filename (data_dirs[i], "autostart", "foo-app.desktop", NULL); g_assert (is_autostart_desktop_file (file)); g_free (file); file = g_build_filename (data_dirs[i], "foo-app.desktop", NULL); g_assert (!is_autostart_desktop_file (file)); g_free (file); } } static void test_get_view_by_path (void) { BamfMatcher *matcher; BamfLegacyScreen *screen; BamfLegacyWindowTest *lwin; BamfApplication *app; BamfWindow *win; GList *app_children; guint32 xid; screen = bamf_legacy_screen_get_default(); matcher = bamf_matcher_get_default (); cleanup_matcher_tables (matcher); export_matcher_on_bus (matcher); xid = g_random_int (); lwin = bamf_legacy_window_test_new (xid, "Window", NULL, NULL); _bamf_legacy_screen_open_test_window (screen, lwin); app = bamf_matcher_get_application_by_xid (matcher, xid); const char *app_path = bamf_view_get_path (BAMF_VIEW (app)); g_assert (app == BAMF_APPLICATION (bamf_matcher_get_view_by_path (matcher, app_path))); app_children = bamf_view_get_children (BAMF_VIEW (app)); g_assert (app_children); win = BAMF_WINDOW (app_children->data); const char *win_path = bamf_view_get_path (BAMF_VIEW (win)); g_assert (win == BAMF_WINDOW (bamf_matcher_get_view_by_path (matcher, win_path))); g_object_unref (matcher); g_object_unref (screen); } static void test_class_valid_name (void) { BamfMatcher *matcher; matcher = bamf_matcher_get_default (); g_assert (bamf_matcher_is_valid_class_name (matcher, "any-good-class")); g_assert (!bamf_matcher_is_valid_class_name (matcher, "sun-awt-X11-XFramePeer")); g_assert (!bamf_matcher_is_valid_class_name (matcher, "net-sourceforge-jnlp-runtime-Boot")); g_assert (!bamf_matcher_is_valid_class_name (matcher, "com-sun-javaws-Main")); g_assert (!bamf_matcher_is_valid_class_name (matcher, "VCLSalFrame")); g_object_unref (matcher); } /* Initialize test suite */ void test_matcher_create_suite (GDBusConnection *connection) { gdbus_connection = connection; g_test_add_func (DOMAIN"/Allocation", test_allocation); g_test_add_func (DOMAIN"/AutostartDesktopFile/User", test_autostart_desktop_file_user); g_test_add_func (DOMAIN"/AutostartDesktopFile/System", test_autostart_desktop_file_system); g_test_add_func (DOMAIN"/ClassValidName", test_class_valid_name); g_test_add_func (DOMAIN"/ExecStringTrimming", test_trim_exec_string); g_test_add_func (DOMAIN"/GetViewByPath", test_get_view_by_path); g_test_add_func (DOMAIN"/LoadDesktopFile", test_load_desktop_file); g_test_add_func (DOMAIN"/LoadDesktopFile/Autostart", test_load_desktop_file_autostart); g_test_add_func (DOMAIN"/LoadDesktopFile/NoDisplay/SameID", test_load_desktop_file_no_display_has_lower_prio_same_id); g_test_add_func (DOMAIN"/LoadDesktopFile/NoDisplay/DifferentID", test_load_desktop_file_no_display_has_lower_prio_different_id); g_test_add_func (DOMAIN"/Matching/Application/DesktopLess", test_match_desktopless_application); g_test_add_func (DOMAIN"/Matching/Application/Desktop", test_match_desktop_application); g_test_add_func (DOMAIN"/Matching/Application/LibreOffice", test_match_libreoffice_windows); g_test_add_func (DOMAIN"/Matching/Application/UnityControlCenter", test_match_unity_control_center_panels); g_test_add_func (DOMAIN"/Matching/Application/JavaWebStart", test_match_javaws_windows); g_test_add_func (DOMAIN"/Matching/Application/JavaWebStart/HintIngored", test_match_javaws_windows_hint_ignored); g_test_add_func (DOMAIN"/Matching/Application/JavaWebStart/NoDesktopMatch", test_match_javaws_windows_no_desktop_match); g_test_add_func (DOMAIN"/Matching/Application/Qml/NoDesktopMatch", test_match_qml_app_no_desktop); g_test_add_func (DOMAIN"/Matching/Application/Qml/DesktopMatch", test_match_qml_app_desktop); g_test_add_func (DOMAIN"/Matching/Application/DesktopFileHintExec", test_match_desktop_file_hint_exec); g_test_add_func (DOMAIN"/Matching/Application/DesktopFileHintExec/Invalid", test_match_desktop_file_hint_exec_invalid); g_test_add_func (DOMAIN"/Matching/Windows/UnmatchedOnNewDesktop", test_new_desktop_matches_unmatched_windows); g_test_add_func (DOMAIN"/Matching/Windows/Transient", test_match_transient_windows); g_test_add_func (DOMAIN"/OpenWindows", test_open_windows); g_test_add_func (DOMAIN"/RegisterDesktopForPid", test_register_desktop_for_pid); g_test_add_func (DOMAIN"/RegisterDesktopForPid/BigNumber", test_register_desktop_for_pid_big_number); g_test_add_func (DOMAIN"/RegisterDesktopForPid/Autostart", test_register_desktop_for_pid_autostart); g_test_add_func (DOMAIN"/RegisterDesktopForPid/Display", test_register_desktop_for_pid_display); g_test_add_func (DOMAIN"/RegisterDesktopForPid/NoDisplay", test_register_desktop_for_pid_nodisplay); } ./tests/Makefile.am.gtests0000644000004100000410000000305514203512426015753 0ustar www-datawww-data# Utility targets for testing. The variable $(TEST_BINARY) defines the binary # to be ran to perform the gtests. # # Author: Marco Trevisan GTESTER2XUNIT_RUN = $(abs_top_srcdir)/tests/gtester2xunit.py # Run tests as part of make check if ENABLE_HEADLESS_TESTS XVFB_RUN = $(abs_top_srcdir)/tests/run-xvfb.sh LOG_PATH = headless-logs test-headless: set -e; \ rm -rf $(LOG_PATH); \ mkdir $(LOG_PATH); \ export LOG_PATH=$(LOG_PATH); \ export XVFB_PATH=$(XVFB); \ export DISPLAY=""; \ export XDG_CURRENT_DESKTOP="Unity"; \ source $(XVFB_RUN); \ \ $(DBUS_RUN_SESSION) -- make $(AM_MAKEFLAGS) -k test; check-local: test-headless else # END HEADLESS TESTS check-local: test endif test: @gtester -k --verbose -o=$(TEST_BINARY)-results.xml ./$(TEST_BINARY); \ $(GTESTER2XUNIT_RUN) -x $(abs_top_srcdir)/tests/gtester.xsl $(TEST_BINARY)-results.xml .PHONY: check-report full-report check-report: $(TEST_BINARY) @gtester -k --verbose -o=$(TEST_BINARY)-results.xml -k ./$(TEST_BINARY) \ && ( gtester-report $(TEST_BINARY)-results.xml \ | sed 's/GTester Unit Test ReportGTester Unit Test Report (normal) $(TEST_BINARY)-results.html ) \ && gnome-open ./$(TEST_BINARY)-results.html full-report: @gtester -k --verbose -o=$(TEST_BINARY)-results.xml -k -m=slow ./$(TEST_BINARY) \ && ( gtester-report $(TEST_BINARY)-results.xml \ | sed 's/>GTester Unit Test ReportGTester Unit Test Report (normal) $(TEST_BINARY)-results.html ) clean-generic: rm -f $(TEST_BINARY)-results*.xml $(TEST_BINARY)-results.html ./tests/run-xvfb.sh0000755000004100000410000000112214203512426014506 0ustar www-datawww-data# This script is based on the one used on dbusmenu project if [ -z "$DISPLAY" ] && [ -x "$XVFB_PATH" ]; then if [ -n "$LOG_PATH" ]; then xvfb_log=$LOG_PATH/Xvfb.out else xvfb_log=/dev/null fi XID=`for id in $(seq 100 150); do test -e /tmp/.X$id-lock || { echo $id; exit 0; }; done; exit 1` { $XVFB_PATH :$XID -ac -noreset -screen 0 800x600x16 -nolisten tcp -auth /dev/null > $xvfb_log 2>&1 & trap "kill -15 $! || true" 0 HUP INT QUIT TRAP USR1 PIPE TERM ; } || { echo "Gtk+Tests:ERROR: Failed to start Xvfb environment for X11 target tests."; exit 1; } DISPLAY=:$XID export DISPLAY fi ./tests/libbamf/0000755000004100000410000000000014203512426014000 5ustar www-datawww-data./tests/libbamf/test-libbamf.c0000644000004100000410000000304314203512426016515 0ustar www-datawww-data/* * Copyright (C) 2013 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by Marco Trevisan * */ #include #include #include #include #include void test_matcher_create_suite (void); void test_application_create_suite (void); static gboolean not_fatal_log_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) { // Don't crash if used return FALSE; } void ignore_fatal_errors (void) { g_test_log_set_fatal_handler (not_fatal_log_handler, NULL); } gint main (gint argc, gchar *argv[]) { g_test_init (&argc, &argv, NULL); const gchar *old_path = g_getenv ("PATH"); gchar *new_path = g_strdup_printf (TESTDIR"/data/bin:%s", old_path); g_setenv ("BAMF_TEST_MODE", "TRUE", TRUE); g_setenv ("PATH", new_path, TRUE); g_free (new_path); test_matcher_create_suite (); test_application_create_suite (); return g_test_run (); } ./tests/libbamf/test-application.c0000644000004100000410000001063614203512426017432 0ustar www-datawww-data/* * Copyright (C) 2013 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by Marco Trevisan (Treviño) * */ #include #include #include #include #include "bamf-view-private.h" #define DATA_DIR TESTDIR "/data" void ignore_fatal_errors (void); static void test_allocation (void) { BamfApplication *application; /* Check it allocates */ application = g_object_new (BAMF_TYPE_APPLICATION, NULL); g_assert (BAMF_IS_APPLICATION (application)); g_object_unref (application); } static void test_favorite_invalid_desktop (void) { BamfApplication *application; application = bamf_application_new_favorite (DATA_DIR"/invalid-type.desktop"); g_assert (!BAMF_IS_APPLICATION (application)); application = bamf_application_new_favorite (DATA_DIR"/not-existing-file.desktop"); g_assert (!BAMF_IS_APPLICATION (application)); ignore_fatal_errors (); application = bamf_application_new_favorite (NULL); g_assert (!BAMF_IS_APPLICATION (application)); } static void test_favorite_valid_desktop_file_system (void) { BamfApplication *application; const gchar *desktop_file = DATA_DIR"/unity-control-center.desktop"; application = bamf_application_new_favorite (desktop_file); g_assert_cmpstr (bamf_application_get_desktop_file (application), ==, desktop_file); g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "System Settings"); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "preferences-system"); g_assert_cmpstr (bamf_application_get_application_type (application), ==, "system"); g_object_unref (application); } static void test_favorite_full_name (void) { BamfApplication *application; application = bamf_application_new_favorite (DATA_DIR"/full-name.desktop"); g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "Full Application Name"); g_object_unref (application); } static void test_favorite_no_icon (void) { BamfApplication *application; application = bamf_application_new_favorite (DATA_DIR"/no-icon.desktop"); g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, BAMF_APPLICATION_DEFAULT_ICON); g_object_unref (application); } static void test_favorite_mime_type_filled (void) { BamfApplication *application; application = bamf_application_new_favorite (TESTDIR"/data/mime-types.desktop"); gchar** mimes = bamf_application_get_supported_mime_types (application); g_assert_cmpuint (g_strv_length (mimes), ==, 7); g_assert_cmpstr (mimes[0], ==, "text/plain"); g_assert_cmpstr (mimes[1], ==, "text/x-chdr"); g_assert_cmpstr (mimes[2], ==, "text/x-csrc"); g_assert_cmpstr (mimes[3], ==, "text/html"); g_assert_cmpstr (mimes[4], ==, "text/css"); g_assert_cmpstr (mimes[5], ==, "text/x-diff"); g_assert_cmpstr (mimes[6], ==, "application/xml"); g_assert_cmpstr (mimes[7], ==, NULL); g_strfreev (mimes); g_object_unref (application); } static void test_favorite_mime_type_empty (void) { BamfApplication *application; application = bamf_application_new_favorite (TESTDIR"/data/test-bamf-app.desktop"); gchar** mimes = bamf_application_get_supported_mime_types (application); g_assert (!mimes); g_object_unref (application); } void test_application_create_suite (void) { #define DOMAIN "/Application" g_test_add_func (DOMAIN"/Allocation", test_allocation); g_test_add_func (DOMAIN"/Favorite/DesktopFile/Invalid", test_favorite_invalid_desktop); g_test_add_func (DOMAIN"/Favorite/DesktopFile/Valid/System", test_favorite_valid_desktop_file_system); g_test_add_func (DOMAIN"/Favorite/FullName", test_favorite_full_name); g_test_add_func (DOMAIN"/Favorite/NoIcon", test_favorite_no_icon); g_test_add_func (DOMAIN"/Favorite/MimeType/Filled", test_favorite_mime_type_filled); g_test_add_func (DOMAIN"/Favorite/MimeType/Empty", test_favorite_mime_type_empty); } ./tests/libbamf/Makefile.am0000644000004100000410000000114514203512426016035 0ustar www-datawww-dataTESTDIR=$(shell realpath $(abs_top_srcdir)/tests) noinst_PROGRAMS = \ test-libbamf test_libbamf_SOURCES = \ test-libbamf.c \ test-application.c \ test-matcher.c \ $(NULL) test_libbamf_CFLAGS = \ -I$(top_srcdir)/lib \ -I$(top_builddir)/lib \ -I$(top_srcdir)/lib/libbamf \ -I$(top_builddir)/lib/libbamf \ -DTESTDIR=\""$(TESTDIR)"\" \ $(COVERAGE_CFLAGS) \ $(GCC_FLAGS) \ $(GLIB_CFLAGS) \ $(NULL) test_libbamf_LDADD = \ $(top_builddir)/lib/libbamf/libbamf$(LIBBAMF_VER).la \ $(COVERAGE_LDFLAGS) \ $(GLIB_LIBS) \ $(NULL) TEST_BINARY = test-libbamf include $(top_srcdir)/tests/Makefile.am.gtests ./tests/libbamf/test-matcher.c0000644000004100000410000000414014203512426016543 0ustar www-datawww-data/* * Copyright (C) 2009-2013 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied 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, see . * * Authored by: Marco Trevisan (Treviño) * Neil Jagdish Patel * */ #include #include #include "libbamf.h" void ignore_fatal_errors (void); static void test_allocation (void) { BamfMatcher *matcher; ignore_fatal_errors(); matcher = bamf_matcher_get_default (); g_assert (BAMF_IS_MATCHER (matcher)); g_object_unref (matcher); } static void test_singleton (void) { BamfMatcher *matcher_1, *matcher_2; ignore_fatal_errors(); matcher_1 = bamf_matcher_get_default (); g_assert (BAMF_IS_MATCHER (matcher_1)); matcher_2 = bamf_matcher_get_default (); g_assert (matcher_1 == matcher_2); g_assert_cmpuint (G_OBJECT (matcher_1)->ref_count, ==, 2); g_object_unref (matcher_2); g_object_unref (matcher_1); } static void test_singleton_after_unref (void) { BamfMatcher *matcher_old, *matcher_new; ignore_fatal_errors(); matcher_old = bamf_matcher_get_default (); g_object_add_weak_pointer (G_OBJECT (matcher_old), (gpointer*) &matcher_old); g_object_unref (matcher_old); g_assert (matcher_old == NULL); matcher_new = bamf_matcher_get_default (); g_assert (matcher_old != matcher_new); g_object_unref (matcher_new); } void test_matcher_create_suite (void) { #define DOMAIN "/Matcher" g_test_add_func (DOMAIN"/Allocation", test_allocation); g_test_add_func (DOMAIN"/Singleton", test_singleton); g_test_add_func (DOMAIN"/SingletonUnref", test_singleton_after_unref); } ./tests/Makefile.am0000644000004100000410000000020114203512426014431 0ustar www-datawww-dataSUBDIRS = \ bamfdaemon \ libbamf \ $(NULL) EXTRA_DIST = \ data \ run-xvfb.sh \ gtester2xunit.py \ gtester.xsl \ $(NULL) ./tests/data/0000755000004100000410000000000014203512426013315 5ustar www-datawww-data./tests/data/ubuntu-web-app.desktop0000644000004100000410000000017214203512426017563 0ustar www-datawww-data[Desktop Entry] Name=Ubuntu Type=Application Icon=ubuntu-icon Exec=unity-webapps-runner -n 'AbCdEfGh=' -d 'ubuntu.com' %u ./tests/data/libreoffice-draw.desktop0000644000004100000410000000020314203512426020107 0ustar www-datawww-data[Desktop Entry] Version=1.0 Terminal=false Icon=libreoffice-draw Type=Application Exec=libreoffice --draw %U Name=LibreOffice Draw ./tests/data/libreoffice-writer.desktop0000644000004100000410000000021114203512426020465 0ustar www-datawww-data[Desktop Entry] Version=1.0 Terminal=false Icon=libreoffice-writer Type=Application Exec=libreoffice --writer %U Name=LibreOffice Writer ./tests/data/bamf-qml-app.desktop0000644000004100000410000000023714203512426017164 0ustar www-datawww-data[Desktop Entry] Name=Bamf Qml APP Exec=qmlscene bamf_qml_app.qml Icon=bamf-qml-icon Terminal=false Type=Application StartupNotify=true OnlyShowIn=GNOME;Unity; ./tests/data/no-display/0000755000004100000410000000000014203512426015374 5ustar www-datawww-data./tests/data/no-display/test-bamf-app.desktop0000644000004100000410000000020714203512426021426 0ustar www-datawww-data[Desktop Entry] Version=1.0 Name=TestBamfApp Type=Application Exec=test-bamf-app Icon=bamf NoDisplay=true StartupWMClass=test_bamf_app ./tests/data/mime-types.desktop0000644000004100000410000000043414203512426017002 0ustar www-datawww-data#!/usr/bin/env xdg-open [Desktop Entry] Name=Mime Text Editor GenericName=Text Editor Exec=mime-test-text-editor %F Terminal=false Type=Application MimeType=text/plain;text/x-chdr;text/x-csrc;text/html;text/css;text/x-diff;application/xml; Categories=TextEditor;Development;Utility; ./tests/data/bin/0000755000004100000410000000000014203512426014065 5ustar www-datawww-data./tests/data/bin/qmlscene0000755000004100000410000000000014203512426015610 0ustar www-datawww-data./tests/data/bin/test-bamf-app0000755000004100000410000000004614203512426016453 0ustar www-datawww-data#!/bin/sh echo "Just a fake program" ./tests/data/bin/libreoffice0000755000004100000410000000004614203512426016264 0ustar www-datawww-data#!/bin/sh echo "Just a fake program" ./tests/data/bin/gedit0000755000004100000410000000004614203512426015107 0ustar www-datawww-data#!/bin/sh echo "Just a fake program" ./tests/data/bin/unity-webapps-runner0000755000004100000410000000004614203512426020131 0ustar www-datawww-data#!/bin/sh echo "Just a fake program" ./tests/data/bin/mime-test-text-editor0000755000004100000410000000004614203512426020165 0ustar www-datawww-data#!/bin/sh echo "Just a fake program" ./tests/data/bin/unity-control-center0000755000004100000410000000004614203512426020117 0ustar www-datawww-data#!/bin/sh echo "Just a fake program" ./tests/data/libreoffice-math.desktop0000644000004100000410000000020314203512426020103 0ustar www-datawww-data[Desktop Entry] Version=1.0 Terminal=false Icon=libreoffice-math Type=Application Exec=libreoffice --math %U Name=LibreOffice Math ./tests/data/icons/0000755000004100000410000000000014203512426014430 5ustar www-datawww-data./tests/data/icons/test-bamf-pixmap.png0000644000004100000410000000000014203512426020302 0ustar www-datawww-data./tests/data/icons/test-bamf-icon.png0000644000004100000410000000000014203512426017734 0ustar www-datawww-data./tests/data/icons/python.png0000644000004100000410000000000014203512426016445 0ustar www-datawww-data./tests/data/icons/python2.7.png0000644000004100000410000000000014203512426016674 0ustar www-datawww-data./tests/data/full-name.desktop0000644000004100000410000000020314203512426016563 0ustar www-datawww-data[Desktop Entry] Type=Application Name=FullName X-GNOME-FullName=Full Application Name Exec=gedit Terminal=false Icon=full-name-icon./tests/data/unity-display-panel.desktop0000644000004100000410000000076514203512426020630 0ustar www-datawww-data[Desktop Entry] Name=Displays Comment=Change resolution and position of monitors and projectors Exec=unity-control-center display Icon=unity-display-panel Terminal=false Type=Application StartupNotify=true Categories=GNOME;GTK;Settings;HardwareSettings;X-Unity-Settings-Panel; OnlyShowIn=Unity; X-Unity-Settings-Panel=display # Translators: those are keywords for the display control-center panel Keywords=Panel;Projector;xrandr;Screen;Resolution;Refresh; X-Ubuntu-Gettext-Domain=unity-control-center ./tests/data/unity-control-center.desktop0000644000004100000410000000042014203512426021010 0ustar www-datawww-data[Desktop Entry] Name=System Settings Icon=preferences-system Exec=unity-control-center --overview Terminal=false Type=Application StartupNotify=true Categories=GNOME;GTK;System; OnlyShowIn=Unity; Keywords=Preferences;Settings; X-Ubuntu-Gettext-Domain=unity-control-center ./tests/data/no-icon.desktop0000644000004100000410000000023014203512426016245 0ustar www-datawww-data[Desktop Entry] Name=Default Comment=Interactive viewer for a Default icon! Exec=gedit Terminal=false Type=Application Categories=GTK;Science;Graphics; ./tests/data/test-bamf-app-display.desktop0000644000004100000410000000017014203512426021011 0ustar www-datawww-data[Desktop Entry] Version=1.0 Name=TestBamfApp Type=Application Exec=test-bamf-app Icon=bamf StartupWMClass=test_bamf_app ./tests/data/unity-mouse-panel.desktop0000644000004100000410000000075414203512426020311 0ustar www-datawww-data[Desktop Entry] Name=Mouse & Touchpad Comment=Set your mouse and touchpad preferences Exec=unity-control-center mouse Icon=input-mouse Terminal=false Type=Application StartupNotify=true Categories=GNOME;GTK;Settings;HardwareSettings;X-Unity-Settings-Panel; OnlyShowIn=Unity; X-Unity-Settings-Panel=mouse # Translators: those are keywords for the mouse and touchpad control-center panel Keywords=Trackpad;Pointer;Click;Tap;Double;Button;Trackball; X-Ubuntu-Gettext-Domain=unity-control-center ./tests/data/libreoffice-startcenter.desktop0000644000004100000410000000017614203512426021521 0ustar www-datawww-data[Desktop Entry] Version=1.0 Terminal=false Icon=libreoffice-startcenter Type=Application Exec=libreoffice %U Name=LibreOffice ./tests/data/test-bamf-app.desktop0000644000004100000410000000017014203512426017346 0ustar www-datawww-data[Desktop Entry] Version=1.0 Name=TestBamfApp Type=Application Exec=test-bamf-app Icon=bamf StartupWMClass=test_bamf_app ./tests/data/icon.desktop0000644000004100000410000000021114203512426015632 0ustar www-datawww-data[Desktop Entry] Name=Test Bamf App with Icon Exec=test-bamf-app Icon=test-bamf-icon Terminal=false Type=Application Categories=Graphics; ./tests/data/libreoffice-base.desktop0000644000004100000410000000020314203512426020064 0ustar www-datawww-data[Desktop Entry] Version=1.0 Terminal=false Icon=libreoffice-base Type=Application Exec=libreoffice --base %U Name=LibreOffice Base ./tests/data/libreoffice-calc.desktop0000644000004100000410000000020314203512426020054 0ustar www-datawww-data[Desktop Entry] Version=1.0 Terminal=false Icon=libreoffice-calc Type=Application Exec=libreoffice --calc %U Name=LibreOffice Calc ./tests/data/invalid-type.desktop0000644000004100000410000000011114203512426017306 0ustar www-datawww-data[Desktop Entry] Name=Invalid Type Exec=gedit Terminal=false Type=FooType ./tests/data/libreoffice-impress.desktop0000644000004100000410000000021414203512426020636 0ustar www-datawww-data[Desktop Entry] Version=1.0 Terminal=false Icon=libreoffice-impress Type=Application Exec=libreoffice --impress %U Name=LibreOffice Impress ./tests/data/icedtea-netx-javaws.desktop0000644000004100000410000000045414203512426020556 0ustar www-datawww-data[Desktop Entry] Name=IcedTea Java Web Start Name[fi]=IcedTea Java - Web Start Comment=IcedTea Java Web Start Comment[fi]=IcedTea Java - Web Start Exec=/usr/bin/javaws %u Terminal=false Type=Application Icon=javaws Categories=Application;Network; MimeType=application/x-java-jnlp-file; NoDisplay=true ./tests/data/test-bamf-app-no-display.desktop0000644000004100000410000000020714203512426021424 0ustar www-datawww-data[Desktop Entry] Version=1.0 Name=TestBamfApp Type=Application Exec=test-bamf-app Icon=bamf NoDisplay=true StartupWMClass=test_bamf_app ./tests/gtester.xsl0000644000004100000410000000615114203512426014614 0ustar www-datawww-data g_test ./COPYING.LGPL0000644000004100000410000001672514203512426013045 0ustar www-datawww-data GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. ./TODO0000644000004100000410000000015614203512426011734 0ustar www-datawww-databamfdaemon should recreate the registered_pids database on restart by inspecting the state of libwnck windows ./Makefile.am0000644000004100000410000000043314203512426013276 0ustar www-datawww-dataACLOCAL_AMFLAGS = -I m4 include $(top_srcdir)/Makefile.am.coverage SUBDIRS = \ lib/libbamf-private \ lib/libbamf \ src \ tests \ data \ doc EXTRA_DIST = COPYING.LGPL autogen.sh build.rules.mk DISTCHECK_CONFIGURE_FLAGS = --enable-introspection=no --enable-gtk-doc=yes ./m4/0000755000004100000410000000000014203512426011562 5ustar www-datawww-data./m4/gcov.m40000644000004100000410000000502614203512426012765 0ustar www-datawww-data# Checks for existence of coverage tools: # * gcov # * lcov # * genhtml # * gcovr # # Sets ac_cv_check_gcov to yes if tooling is present # and reports the executables to the variables LCOV, GCOVR and GENHTML. AC_DEFUN([AC_TDD_GCOV], [ AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [enable coverage testing with gcov]), [use_gcov=$enableval], [use_gcov=no]) AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes") if test "x$use_gcov" = "xyes"; then # we need gcc: if test "$GCC" != "yes"; then AC_MSG_ERROR([GCC is required for --enable-gcov]) fi # Check if ccache is being used AC_CHECK_PROG(SHTOOL, shtool, shtool) if test "$SHTOOL"; then AS_CASE([`$SHTOOL path $CC`], [*ccache*], [gcc_ccache=yes], [gcc_ccache=no]) fi if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) fi lcov_version_list="1.6 1.7 1.8 1.9 1.10 1.11 1.12" AC_CHECK_PROG(LCOV, lcov, lcov) AC_CHECK_PROG(GENHTML, genhtml, genhtml) if test "$LCOV"; then AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ glib_cv_lcov_version=invalid lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` for lcov_check_version in $lcov_version_list; do if test "$lcov_version" = "$lcov_check_version"; then glib_cv_lcov_version="$lcov_check_version (ok)" fi done ]) else lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" AC_MSG_ERROR([$lcov_msg]) fi case $glib_cv_lcov_version in ""|invalid[)] lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." AC_MSG_ERROR([$lcov_msg]) LCOV="exit 0;" ;; esac if test -z "$GENHTML"; then AC_MSG_ERROR([Could not find genhtml from the lcov package]) fi ac_cv_check_gcov=yes ac_cv_check_lcov=yes # Remove all optimization flags from CFLAGS changequote({,}) CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` changequote([,]) # Add the special gcc flags COVERAGE_CFLAGS="-O0 --coverage" COVERAGE_CXXFLAGS="-O0 --coverage" COVERAGE_LDFLAGS="-lgcov" # Check availability of gcovr AC_CHECK_PROG(GCOVR, gcovr, gcovr) if test -z "$GCOVR"; then ac_cv_check_gcovr=no else ac_cv_check_gcovr=yes fi fi ]) # AC_TDD_GCOV ./doc/0000755000004100000410000000000014203512426012007 5ustar www-datawww-data./doc/reference/0000755000004100000410000000000014203512426013745 5ustar www-datawww-data./doc/reference/libbamf/0000755000004100000410000000000014203512426015341 5ustar www-datawww-data./doc/reference/libbamf/libbamf.types0000644000004100000410000000022614203512426020023 0ustar www-datawww-databamf_application_get_type bamf_control_get_type bamf_factory_get_type bamf_matcher_get_type bamf_tab_get_type bamf_view_get_type bamf_window_get_type ./doc/reference/libbamf/libbamf-docs.sgml0000644000004100000410000000205514203512426020551 0ustar www-datawww-data ]> libbamf Reference Manual Classes Object Hierarchy API Index ./doc/reference/libbamf/Makefile.am0000644000004100000410000000274414203512426017404 0ustar www-datawww-data## Process this file with automake to produce Makefile.in # automake requirements AUTOMAKE_OPTIONS = 1.7 # The name of the module DOC_MODULE=libbamf # The top-level SGML file. You can change this if you want to. DOC_MAIN_SGML_FILE = $(DOC_MODULE)-docs.sgml # The directory containing the source code. Relative to $(srcdir). DOC_SOURCE_DIR = ../../../lib/libbamf # Extra options to pass to gtkdoc-scangobj. Not normally needed. SCANGOBJ_OPTIONS = # Extra options to supply to gtkdoc-scan. # Fx --rebuild-types --rebuild-sections SCAN_OPTIONS = # Extra options to supply to gtkdoc-mkdb. MKDB_OPTIONS = --sgml-mode --output-format=xml --ignore-files=trio # Extra options to supply to gtkdoc-fixref. Not normally needed. FIXXREF_OPTIONS = # Used for dependencies. The docs will be rebuilt if any of these change. HFILE_GLOB = $(top_srcdir)/lib/libbamf/bamf-*.h CFILE_GLOB = $(top_srcdir)/lib/libbamf/bamf-*.c # Images to copy into HTML directory. HTML_IMAGES = # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). content_files = # CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. INCLUDES= \ -I$(top_srcdir)/lib/libbamf \ $(GTK_CFLAGS) \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) GTKDOC_LIBS = \ $(GTK_LIBS) \ $(GLIB_LIBS) \ $(top_builddir)/lib/libbamf/libbamf$(LIBBAMF_VER).la # This includes the standard gtk-doc make rules, copied by gtkdocize. include $(top_srcdir)/gtk-doc.make # Other files to distribute # e.g. EXTRA_DIST += version.xml.in EXTRA_DIST += ./doc/reference/Makefile.am0000644000004100000410000000002214203512426015773 0ustar www-datawww-dataSUBDIRS = libbamf ./doc/Makefile.am0000644000004100000410000000002414203512426014037 0ustar www-datawww-dataSUBDIRS = reference ./AUTHORS0000644000004100000410000000000014203512426012300 0ustar www-datawww-data./data/0000755000004100000410000000000014203512426012153 5ustar www-datawww-data./data/bamfdaemon.conf.in0000644000004100000410000000044614203512426015524 0ustar www-datawww-datadescription "BAMF Application Matcher Framework" author "Marco Trevisan " start on (starting hud or starting unity-panel-service or starting unity7) stop on (stopped hud and stopped unity-panel-service and stopped unity7) respawn exec @PKGLIBEXECDIR@/bamfdaemon ./data/bamfdaemon-dbus-runner.in0000644000004100000410000000045614203512426017043 0ustar www-datawww-data#!/bin/bash if [ -n "$UPSTART_SESSION" ] && ! systemctl --user --quiet is-active graphical-session.target; then if ! (initctl status bamfdaemon | grep -q start); then /sbin/initctl start bamfdaemon else echo "bamfdaemon job is already running..." fi else @PKGLIBEXECDIR@/bamfdaemon fi ./data/bamfdaemon.service.in0000644000004100000410000000027414203512426016236 0ustar www-datawww-data[Unit] Description=BAMF Application Matcher Framework PartOf=graphical-session.target [Service] Type=dbus BusName=org.ayatana.bamf ExecStart=@PKGLIBEXECDIR@/bamfdaemon Restart=on-failure ./data/org.ayatana.bamf.service.in0000644000004100000410000000016414203512426017253 0ustar www-datawww-data[D-BUS Service] Name=org.ayatana.bamf Exec=@PKGLIBEXECDIR@/bamfdaemon-dbus-runner SystemdService=bamfdaemon.service ./data/Makefile.am0000644000004100000410000000204114203512426014204 0ustar www-datawww-dataservicedir = @datarootdir@/dbus-1/services service_DATA = org.ayatana.bamf.service upstartdir = @datarootdir@/upstart/sessions upstart_DATA = bamfdaemon.conf systemddir = /usr/lib/systemd/user systemd_DATA = bamfdaemon.service bamfdaemondbusrunnerdir = $(pkglibexecdir) bamfdaemondbusrunner_SCRIPTS = bamfdaemon-dbus-runner org.ayatana.bamf.service: org.ayatana.bamf.service.in $(AM_V_GEN)sed "s,@PKGLIBEXECDIR@,$(pkglibexecdir)," $< > $@ bamfdaemon.conf: bamfdaemon.conf.in $(AM_V_GEN)sed "s,@PKGLIBEXECDIR@,$(pkglibexecdir)," $< > $@ bamfdaemon.service: bamfdaemon.service.in $(AM_V_GEN)sed "s,@PKGLIBEXECDIR@,$(pkglibexecdir)," $< > $@ bamfdaemon-dbus-runner: bamfdaemon-dbus-runner.in $(AM_V_GEN)sed "s,@PKGLIBEXECDIR@,$(pkglibexecdir)," $< > $@ EXTRA_DIST = org.ayatana.bamf.service.in \ bamfdaemon.conf.in \ bamfdaemon.service.in \ bamfdaemon-dbus-runner.in CLEANFILES = org.ayatana.bamf.service \ bamfdaemon.conf \ bamfdaemon.service \ bamfdaemon-dbus-runner