./0000755000004100000410000000000013700622663011250 5ustar www-datawww-data./Makefile.am.marshal0000644000004100000410000000223613700622663014735 0ustar www-datawww-data# Rules for generating marshal files using glib-genmarshal # # Define: # glib_marshal_list = marshal list file # glib_marshal_prefix = prefix for marshal functions # # before including Makefile.am.marshal. You will also need to have # the following targets already defined: # # CLEANFILES # DISTCLEANFILES # BUILT_SOURCES # EXTRA_DIST # # Author: Emmanuele Bassi marshal_h = $(glib_marshal_list:.list=.h) marshal_c = $(glib_marshal_list:.list=.c) CLEANFILES += stamp-marshal DISTCLEANFILES += $(marshal_h) $(marshal_c) BUILT_SOURCES += $(marshal_h) $(marshal_c) EXTRA_DIST += $(glib_marshal_list) stamp-marshal: $(glib_marshal_list) $(QUIET_GEN)$(GLIB_GENMARSHAL) \ --prefix=$(glib_marshal_prefix) \ --header \ $(srcdir)/$(glib_marshal_list) > xgen-mh \ && (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \ && rm -f xgen-mh \ && echo timestamp > $(@F) $(marshal_h): stamp-marshal @true $(marshal_c): $(marshal_h) $(QUIET_GEN)(echo "#include \"$(marshal_h)\"" ; \ $(GLIB_GENMARSHAL) \ --prefix=$(glib_marshal_prefix) \ --body \ $(srcdir)/$(glib_marshal_list)) > xgen-mc \ && cp xgen-mc $(marshal_c) \ && rm -f xgen-mc ./NEWS0000644000004100000410000000000013700622663011735 0ustar www-datawww-data./acinclude.m40000644000004100000410000002236413700622663013450 0ustar www-datawww-data## ------------------------ ## Python file handling ## From Andrew Dalke ## Updated by James Henstridge ## ------------------------ # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # Adds support for distributing Python modules and packages. To # install modules, copy them to $(pythondir), using the python_PYTHON # automake variable. To install a package with the same name as the # automake package, install to $(pkgpythondir), or use the # pkgpython_PYTHON automake variable. # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as # locations to install python extension modules (shared libraries). # Another macro is required to find the appropriate flags to compile # extension modules. # If your package is configured with a different prefix to python, # users will have to add the install directory to the PYTHONPATH # environment variable, or create a .pth file (see the python # documentation for details). # If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will # cause an error if the version of python installed on the system # doesn't meet the requirement. MINIMUM-VERSION should consist of # numbers and dots only. AC_DEFUN([AM_PATH_PYTHON], [ dnl Find a Python interpreter. Python versions prior to 1.5 are not dnl supported because the default installation locations changed from dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages dnl in 1.5. m4_define([_AM_PYTHON_INTERPRETER_LIST], [python python2 python2.4 python2.3 python2.2 dnl python2.1 python2.0 python1.6 python1.5]) m4_if([$1],[],[ dnl No version check is needed. # Find any Python interpreter. if test -z "$PYTHON"; then PYTHON=: AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST) fi am_display_PYTHON=python ], [ dnl A version check is needed. if test -n "$PYTHON"; then # If the user set $PYTHON, use it and don't search something else. AC_MSG_CHECKING([whether $PYTHON version >= $1]) AM_PYTHON_CHECK_VERSION([$PYTHON], [$1], [AC_MSG_RESULT(yes)], [AC_MSG_ERROR(too old)]) am_display_PYTHON=$PYTHON else # Otherwise, try each interpreter until we find one that satisfies # VERSION. AC_CACHE_CHECK([for a Python interpreter with version >= $1], [am_cv_pathless_PYTHON],[ for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do test "$am_cv_pathless_PYTHON" = none && break AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) done]) # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. if test "$am_cv_pathless_PYTHON" = none; then PYTHON=: else AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON]) fi am_display_PYTHON=$am_cv_pathless_PYTHON fi ]) if test "$PYTHON" = :; then dnl Run any user-specified action, or abort. m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])]) else dnl Query Python for its version number. Getting [:3] seems to be dnl the best way to do this; it's what "site.py" does in the standard dnl library. AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version], [am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`]) AC_SUBST([PYTHON_VERSION], [$am_cv_python_version]) dnl Use the values of $prefix and $exec_prefix for the corresponding dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made dnl distinct variables so they can be overridden if need be. However, dnl general consensus is that you shouldn't need this ability. AC_SUBST([PYTHON_PREFIX], ['${prefix}']) AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}']) dnl At times (like when building shared libraries) you may want dnl to know which OS platform Python thinks this is. AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform], [am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`]) AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform]) dnl Set up 4 directories: dnl pythondir -- where to install python scripts. This is the dnl site-packages directory, not the python standard library dnl directory like in previous automake betas. This behavior dnl is more consistent with lispdir.m4 for example. dnl Query distutils for this directory. distutils does not exist in dnl Python 1.5, so we fall back to the hardcoded directory if it dnl doesn't work. AC_CACHE_CHECK([for $am_display_PYTHON script directory], [am_cv_python_pythondir], [am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null || echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`]) AC_SUBST([pythondir], [$am_cv_python_pythondir]) dnl pkgpythondir -- $PACKAGE directory under pythondir. Was dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is dnl more consistent with the rest of automake. AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE]) dnl pyexecdir -- directory for installing python extension modules dnl (shared libraries) dnl Query distutils for this directory. distutils does not exist in dnl Python 1.5, so we fall back to the hardcoded directory if it dnl doesn't work. AC_CACHE_CHECK([for $am_display_PYTHON extension module directory], [am_cv_python_pyexecdir], [am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null || echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`]) AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir]) dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE) AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE]) dnl Run any user-specified action. $2 fi ]) # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # --------------------------------------------------------------------------- # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION. # Run ACTION-IF-FALSE otherwise. # This test uses sys.hexversion instead of the string equivalent (first # word of sys.version), in order to cope with versions such as 2.2c1. # hexversion has been introduced in Python 1.5.2; it's probably not # worth to support older versions (1.5.1 was released on October 31, 1998). AC_DEFUN([AM_PYTHON_CHECK_VERSION], [prog="import sys, string # split strings by '.' and convert to numeric. Append some zeros # because we need at least 4 digits for the hex conversion. minver = map(int, string.split('$2', '.')) + [[0, 0, 0]] minverhex = 0 for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]] sys.exit(sys.hexversion < minverhex)" AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) python.m4 ## this one is commonly used with AM_PATH_PYTHONDIR ... dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]]) dnl Check if a module containing a given symbol is visible to python. AC_DEFUN([AM_CHECK_PYMOD], [AC_REQUIRE([AM_PATH_PYTHON]) py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'` AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1) AC_CACHE_VAL(py_cv_mod_$py_mod_var, [ ifelse([$2],[], [prog=" import sys try: import $1 except ImportError: sys.exit(1) except: sys.exit(0) sys.exit(0)"], [prog=" import $1 $1.$2"]) if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC then eval "py_cv_mod_$py_mod_var=yes" else eval "py_cv_mod_$py_mod_var=no" fi ]) py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"` if test "x$py_val" != xno; then AC_MSG_RESULT(yes) ifelse([$3], [],, [$3 ])dnl else AC_MSG_RESULT(no) ifelse([$4], [],, [$4 ])dnl fi ]) dnl a macro to check for ability to create python extensions dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE]) dnl function also defines PYTHON_INCLUDES AC_DEFUN([AM_CHECK_PYTHON_HEADERS], [AC_REQUIRE([AM_PATH_PYTHON]) AC_MSG_CHECKING(for headers required to compile python extensions) dnl deduce PYTHON_INCLUDES py_prefix=`$PYTHON -c "import sys; print sys.prefix"` py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` PYTHON_INCLUDES="`$PYTHON-config --includes`" if test "$py_prefix" != "$py_exec_prefix"; then PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" fi AC_SUBST(PYTHON_INCLUDES) dnl check if the headers exist: save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" AC_TRY_CPP([#include ],dnl [AC_MSG_RESULT(found) $1],dnl [AC_MSG_RESULT(not found) $2]) CPPFLAGS="$save_CPPFLAGS" ]) ./configure.ac0000644000004100000410000001500213700622663013534 0ustar www-datawww-dataAC_INIT([libappindicator], [12.10.0], [http://bugs.launchpad.net/libappindicator], [libappindicator], [http://launchpad.net/libappindicator]) AC_COPYRIGHT([Copyright 2009, 2010 Canonical]) AC_PREREQ([2.64]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([1.11 -Wall tar-pax]) AM_MAINTAINER_MODE([enable]) AM_SILENT_RULES([yes]) # Check for programs AC_PROG_CC AM_PROG_CC_C_O # Initialize libtool LT_PREREQ([2.2]) LT_INIT AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums]) AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal]) PKG_PROG_PKG_CONFIG ########################### # GTK Doc ########################### GTK_DOC_CHECK([1.14],[--flavour no-tmpl]) ########################### # Dependencies ########################### GTK_REQUIRED_VERSION=2.18 GTK3_REQUIRED_VERSION=2.91 GLIB_REQUIRED_VERSION=2.35.4 GIO_REQUIRED_VERSION=2.26 DBUSMENUGTK_REQUIRED_VERSION=0.5.90 DBUS_GLIB_REQUIRED_VERSION=0.82 AC_ARG_WITH([gtk], [AS_HELP_STRING([--with-gtk], [Which version of gtk to use @<:@default=2@:>@])], [], [with_gtk=2]) AS_IF([test "x$with_gtk" = x3], [PKG_CHECK_MODULES(LIBRARY, gtk+-3.0 >= $GTK3_REQUIRED_VERSION glib-2.0 >= $GLIB_REQUIRED_VERSION gio-unix-2.0 gio-2.0 >= $GIO_REQUIRED_VERSION dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION) AC_DEFINE(HAVE_GTK3, 1, [whether gtk3 is available]) ], [test "x$with_gtk" = x2], [PKG_CHECK_MODULES(LIBRARY, gtk+-2.0 >= $GTK_REQUIRED_VERSION glib-2.0 >= $GLIB_REQUIRED_VERSION gio-unix-2.0 gio-2.0 >= $GIO_REQUIRED_VERSION dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION) ], [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])] ) AM_CONDITIONAL(USE_GTK3, [test "x$with_gtk" = x3]) PKG_CHECK_MODULES(TESTDEPS, dbus-glib-1) ########################### # GObject Introspection ########################### GOBJECT_INTROSPECTION_CHECK([0.6.7]) PKG_CHECK_EXISTS([gobject-introspection-1.0 >= 0.10], introspection_ten=yes, introspection_ten=no) AM_CONDITIONAL(INTROSPECTION_TEN, [test "x$introspection_ten" = "xyes"]) ########################### # Vala API Generation ########################### AC_PATH_PROG([VALA_API_GEN], [vapigen]) AM_CONDITIONAL(HAVE_VAPIGEN, [test "x$VALA_API_GEN" != "x"]) ########################### # Vala Compiler support ########################### AM_PROG_VALAC([0.14.0]) AM_CONDITIONAL(HAVE_VALAC, [test "x$VALAC" != "x"]) ########################### # Check for Mono support ########################### MONO_REQUIRED_VERSION=1.0 PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false) AM_CONDITIONAL(HAS_MONO, [test "x$has_mono" = "xtrue"]) AC_PATH_PROG(AL, al, no) if test "x$AL" = "xno" ; then AC_MSG_NOTICE([No al tool found. You need to install Mono.]) fi if test "x$has_mono" = "xtrue" ; then GENERATED_SOURCES=generated/*.cs AC_PATH_PROG(RUNTIME, mono, no) if test "x$RUNTIME" != "no" ; then RUNTIME=mono fi AC_PATH_PROG(CSC, mono-csc, no) LIB_PREFIX=.so LIB_SUFFIX= fi if test "x$CSC" = "xno" ; then AC_MSG_NOTICE([No Mono compiler found.]) fi AC_PATH_PROG(GACUTIL, gacutil, no) if test "x$GACUTIL" = "xno" ; then AC_MSG_NOTICE([No gacutil tool found]) fi AC_SUBST(RUNTIME) AC_SUBST(CSC) AC_SUBST(GACUTIL) AC_SUBST(LIB_PREFIX) AC_SUBST(LIB_SUFFIX) AC_SUBST(GENERATED_SOURCES) GLIB_SHARP_REQ_VERSION=2.12.1 GTK_SHARP_REQ_VERSION=2.12 PKG_CHECK_MODULES(GTK_SHARP, gtk-sharp-2.0 >= $GTK_SHARP_REQ_VERSION, has_gtksharp=true, has_gtksharp=false) PKG_CHECK_MODULES(GAPI, gapi-2.0 >= $GLIB_SHARP_REQ_VERSION, has_gapi=true, has_gapi=false) AC_PATH_PROG(GAPI_PARSER, gapi2-parser, no) AC_SUBST(GAPI_PARSER) AC_PATH_PROG(GAPI_CODEGEN, gapi2-codegen, no) AC_SUBST(GAPI_CODEGEN) AC_PATH_PROG(GAPI_FIXUP, gapi2-fixup, no) AC_SUBST(GAPI_FIXUP) # Check for nunit AC_ARG_ENABLE([mono-test], AC_HELP_STRING([--disable-mono-test], [Disable mono test]),, [enable_mono_test=auto]) if test x"$enable_mono_test" != x"no" ; then PKG_CHECK_MODULES(NUNIT, nunit >= 2.4.7, [have_nunit=yes], [PKG_CHECK_MODULES(MONO_NUNIT, mono-nunit, [have_nunit=yes], [have_nunit=no]) ]) if test x${enable_mono_test} = xyes && test x${have_nunit} = xno; then AC_MSG_ERROR([Mono test configured but nunit not found]) fi else have_nunit=no fi AM_CONDITIONAL(BUILD_MONO_TEST, test x${have_nunit} = xyes) ########################### # Check to see if we're local ########################### with_localinstall="no" AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [install all of the files localy instead of system directories (for distcheck)]), with_localinstall=$enableval, with_localinstall=no) ######################### # Check if build tests ######################### AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests], [Disable tests]),, [enable_tests=yes]) AM_CONDITIONAL([WANT_TESTS], [test "x$enable_tests" != "xno"]) ########################### # gcov coverage reporting ########################### m4_include([m4/gcov.m4]) 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_CXXFLAGS) AC_SUBST(COVERAGE_LDFLAGS) ########################### # Files ########################### AC_CONFIG_FILES([ Makefile src/Makefile src/appindicator-0.1.pc src/appindicator3-0.1.pc bindings/Makefile bindings/vala/Makefile bindings/vala/examples/Makefile tests/Makefile example/Makefile docs/Makefile docs/reference/Makefile docs/reference/version.xml docs/reference/libappindicator-docs.sgml ]) if test "x$has_mono" = "xtrue" ; then AC_CONFIG_FILES([ bindings/mono/Makefile bindings/mono/appindicator-sharp.dll.config bindings/mono/appindicator-sharp-0.1.pc bindings/mono/app-indicator.sources.xml bindings/mono/examples/Makefile bindings/mono/examples/indicator-example ]) fi AC_OUTPUT ########################### # Results ########################### AC_MSG_NOTICE([ Libappindicator Configuration: Prefix: $prefix GTK+ Version: $with_gtk Mono: $has_mono Tests: $enable_tests Mono tests: $have_nunit gcov: $use_gcov ]) ./README0000644000004100000410000000020713700622663012127 0ustar www-datawww-dataA readme is the very beginning, a very nice place to start. When you read you begin with A-B-C when you code you begin with RE-AD-ME! ./example/0000755000004100000410000000000013700622663012703 5ustar www-datawww-data./example/simple-client.c0000644000004100000410000001625513700622663015625 0ustar www-datawww-data/* A small piece of sample code demonstrating a very simple application with an indicator. Copyright 2009 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #include "app-indicator.h" #include "libdbusmenu-glib/server.h" #include "libdbusmenu-glib/menuitem.h" GMainLoop * mainloop = NULL; static gboolean active = TRUE; static gboolean can_haz_label = TRUE; static void label_toggle_cb (GtkWidget * widget, gpointer data) { can_haz_label = !can_haz_label; if (can_haz_label) { gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Hide label"); } else { gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Show label"); } return; } static void activate_clicked_cb (GtkWidget *widget, gpointer data) { AppIndicator * ci = APP_INDICATOR(data); if (active) { app_indicator_set_status (ci, APP_INDICATOR_STATUS_ATTENTION); gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "I'm okay now"); active = FALSE; } else { app_indicator_set_status (ci, APP_INDICATOR_STATUS_ACTIVE); gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Get Attention"); active = TRUE; } } static void local_icon_toggle_cb (GtkWidget *widget, gpointer data) { AppIndicator * ci = APP_INDICATOR(data); if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) { app_indicator_set_icon_full(ci, LOCAL_ICON, "Local Icon"); } else { app_indicator_set_icon_full(ci, "indicator-messages", "System Icon"); } return; } static void item_clicked_cb (GtkWidget *widget, gpointer data) { const gchar *text = (const gchar *)data; g_print ("%s clicked!\n", text); } static void toggle_sensitivity_cb (GtkWidget *widget, gpointer data) { GtkWidget *target = (GtkWidget *)data; gtk_widget_set_sensitive (target, !gtk_widget_is_sensitive (target)); } static void image_clicked_cb (GtkWidget *widget, gpointer data) { gtk_image_set_from_stock (GTK_IMAGE (gtk_image_menu_item_get_image ( GTK_IMAGE_MENU_ITEM (widget))), GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU); } static void scroll_event_cb (AppIndicator * ci, gint delta, guint direction, gpointer data) { g_print("Got scroll event! delta: %d, direction: %d\n", delta, direction); } static void append_submenu (GtkWidget *item) { GtkWidget *menu; GtkWidget *mi; GtkWidget *prev_mi; menu = gtk_menu_new (); mi = gtk_menu_item_new_with_label ("Sub 1"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); g_signal_connect (mi, "activate", G_CALLBACK (item_clicked_cb), "Sub 1"); prev_mi = mi; mi = gtk_menu_item_new_with_label ("Sub 2"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); g_signal_connect (mi, "activate", G_CALLBACK (toggle_sensitivity_cb), prev_mi); mi = gtk_menu_item_new_with_label ("Sub 3"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); g_signal_connect (mi, "activate", G_CALLBACK (item_clicked_cb), "Sub 3"); gtk_widget_show_all (menu); gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu); } guint percentage = 0; static gboolean percent_change (gpointer user_data) { percentage = (percentage + 1) % 100; if (can_haz_label) { gchar * percentstr = g_strdup_printf("%d%%", percentage + 1); app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%"); g_free(percentstr); } else { app_indicator_set_label (APP_INDICATOR(user_data), NULL, NULL); } return TRUE; } int main (int argc, char ** argv) { GtkWidget *menu = NULL; AppIndicator *ci = NULL; gtk_init (&argc, &argv); ci = app_indicator_new ("example-simple-client", "indicator-messages", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_assert (IS_APP_INDICATOR (ci)); g_assert (G_IS_OBJECT (ci)); app_indicator_set_status (ci, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_attention_icon_full(ci, "indicator-messages-new", "System Messages Icon Highlighted"); app_indicator_set_label (ci, "1%", "100%"); app_indicator_set_title (ci, "Test Inidcator"); g_signal_connect (ci, "scroll-event", G_CALLBACK (scroll_event_cb), NULL); g_timeout_add_seconds(1, percent_change, ci); menu = gtk_menu_new (); GtkWidget *item = gtk_check_menu_item_new_with_label ("1"); g_signal_connect (item, "activate", G_CALLBACK (item_clicked_cb), "1"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); item = gtk_radio_menu_item_new_with_label (NULL, "2"); g_signal_connect (item, "activate", G_CALLBACK (item_clicked_cb), "2"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); item = gtk_menu_item_new_with_label ("3"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); append_submenu (item); gtk_widget_show (item); GtkWidget *toggle_item = gtk_menu_item_new_with_label ("Toggle 3"); g_signal_connect (toggle_item, "activate", G_CALLBACK (toggle_sensitivity_cb), item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), toggle_item); gtk_widget_show(toggle_item); item = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, NULL); g_signal_connect (item, "activate", G_CALLBACK (image_clicked_cb), NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show(item); item = gtk_menu_item_new_with_label ("Get Attention"); g_signal_connect (item, "activate", G_CALLBACK (activate_clicked_cb), ci); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show(item); app_indicator_set_secondary_activate_target(ci, item); item = gtk_menu_item_new_with_label ("Show label"); label_toggle_cb(item, ci); g_signal_connect (item, "activate", G_CALLBACK (label_toggle_cb), ci); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show(item); item = gtk_check_menu_item_new_with_label ("Set Local Icon"); g_signal_connect (item, "activate", G_CALLBACK (local_icon_toggle_cb), ci); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show(item); app_indicator_set_menu (ci, GTK_MENU (menu)); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); return 0; } ./example/simple-client-vala.vala0000644000004100000410000001103213700622663017233 0ustar www-datawww-data/* A small piece of sample code demonstrating a very simple application with an indicator. Copyright 2011 Canonical Ltd. Authors: Marco Trevisan 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ using Gtk; using AppIndicator; static int main(string[] args) { var sc = new SimpleClient(args); sc.run(); return 0; } class SimpleClient { Gtk.Menu menu; Indicator ci; int percentage; bool active; bool can_haz_label; public SimpleClient(string[] args) { Gtk.init(ref args); ci = new Indicator("example-simple-client", "indicator-messages", IndicatorCategory.APPLICATION_STATUS); ci.set_status(IndicatorStatus.ACTIVE); ci.set_attention_icon("indicator-messages-new"); ci.set_label("1%", "100%"); ci.set_title("Test Indicator (vala)"); active = true; can_haz_label = true; } private void toggle_sensitivity(Widget widget) { widget.set_sensitive(!widget.is_sensitive()); } private void append_submenu(Gtk.MenuItem item) { var menu = new Gtk.Menu(); Gtk.MenuItem mi; mi = new Gtk.MenuItem.with_label("Sub 1"); menu.append(mi); mi.activate.connect(() => { print("Sub1\n"); }); Gtk.MenuItem prev_mi = mi; mi = new Gtk.MenuItem.with_label("Sub 2"); menu.append(mi); mi.activate.connect(() => { toggle_sensitivity(prev_mi); }); mi = new Gtk.MenuItem.with_label("Sub 3"); menu.append(mi); mi.activate.connect(() => { print("Sub3\n"); }); mi = new Gtk.MenuItem.with_label("Toggle Attention"); menu.append(mi); mi.activate.connect(() => { if (ci.get_status() == IndicatorStatus.ATTENTION) ci.set_status(IndicatorStatus.ACTIVE); else ci.set_status(IndicatorStatus.ATTENTION); }); ci.set_secondary_activate_target(mi); menu.show_all(); item.set_submenu(menu); } private void label_toggle(Gtk.MenuItem item) { can_haz_label = !can_haz_label; if (can_haz_label) { item.set_label("Hide label"); } else { item.set_label("Show label"); } } public void run() { ci.scroll_event.connect((delta, direction) => { print(@"Got scroll event! delta: $delta, direction: $direction\n"); }); GLib.Timeout.add_seconds(1, () => { percentage = (percentage + 1) % 100; if (can_haz_label) { ci.set_label(@"$(percentage+1)%", ""); } else { ci.set_label("", ""); } return true; }); menu = new Gtk.Menu(); var chk = new CheckMenuItem.with_label("1"); chk.activate.connect(() => { print("1\n"); }); menu.append(chk); chk.show(); var radio = new Gtk.RadioMenuItem.with_label(new SList(), "2"); radio.activate.connect(() => { print("2\n"); }); menu.append(radio); radio.show(); var submenu = new Gtk.MenuItem.with_label("3"); menu.append(submenu); append_submenu(submenu); submenu.show(); var toggle_item = new Gtk.MenuItem.with_label("Toggle 3"); toggle_item.activate.connect(() => { toggle_sensitivity(submenu); }); menu.append(toggle_item); toggle_item.show(); var imgitem = new Gtk.ImageMenuItem.from_stock(Stock.NEW, null); imgitem.activate.connect(() => { Image img = (Image) imgitem.get_image(); img.set_from_stock(Stock.OPEN, IconSize.MENU); }); menu.append(imgitem); imgitem.show(); var att = new Gtk.MenuItem.with_label("Get Attention"); att.activate.connect(() => { if (active) { ci.set_status(IndicatorStatus.ATTENTION); att.set_label("I'm okay now"); active = false; } else { ci.set_status(IndicatorStatus.ACTIVE); att.set_label("Get Attention"); active = false; } }); menu.append(att); att.show(); var show = new Gtk.MenuItem.with_label("Show Label"); label_toggle(show); show.activate.connect(() => { label_toggle(show); }); menu.append(show); show.show(); var icon = new Gtk.CheckMenuItem.with_label("Set Local Icon"); icon.activate.connect(() => { if (icon.get_active()) { ci.set_icon("simple-client-test-icon.png"); } else { ci.set_icon("indicator-messages"); } }); menu.append(icon); icon.show(); ci.set_menu(menu); Gtk.main(); } } ./example/Makefile.am0000644000004100000410000000236013700622663014740 0ustar www-datawww-dataif USE_GTK3 VER=3 else VER= endif CLEANFILES = EXTRA_DIST = check_PROGRAMS = \ simple-client \ simple-client-vala ######################################### ## simple-client ######################################### simple_client_SOURCES = \ simple-client.c #-Werror removed for Vala simple_client_CFLAGS = \ $(LIBRARY_CFLAGS) \ -DLOCAL_ICON="\"$(abs_srcdir)/simple-client-test-icon.png\"" \ -Wall \ -I$(top_srcdir)/src simple_client_LDADD = \ $(LIBRARY_LIBS) \ $(top_builddir)/src/libappindicator$(VER).la EXTRA_DIST += \ simple-client-test-icon.png ######################################### ## simple-client-vala ######################################### if HAVE_VALAC VALAFLAGS = \ --pkg appindicator$(VER)-0.1 \ --vapidir=$(top_builddir)/bindings/vala BUILT_SOURCES = simple-client-vala.c simple-client-vala.c: $(srcdir)/simple-client-vala.vala $(VALAC) $(VALAFLAGS) -C $< -o $@ $(SED) -i "s|#include\s*<\s*libappindicator/app-indicator.h\s*>||g" $@ simple_client_vala_SOURCES = simple-client-vala.c simple_client_vala_CFLAGS = \ $(simple_client_CFLAGS) \ -include $(top_srcdir)/src/app-indicator.h simple_client_vala_LDADD = $(simple_client_LDADD) CLEANFILES += *.stamp *-vala.c endif EXTRA_DIST += \ simple-client-vala.vala ./example/simple-client-test-icon.png0000644000004100000410000000635613700622663020073 0ustar www-datawww-dataPNG  IHDR$$nbsRGB pHYs  tIME ,IOztEXtCommentCreated with GIMPW [IDATHuWY\Y>ݪn^ܫێ1 8b|_'.w/>*bH(c7~s !DA! omx3zB0Q䦦'3)"-JBHIW!AEÊѢD5ѳ )RJ `5 +ZܩrBQrpO=u}rsc7X0üVGi C"L#tbaga}˲  ϗB-W>p JoCPWBa hx&z, zA~v~꩟S!h4:q*2>QY(X "c'>oQș\Plg1| gN[ZZ4탭ǵ MOOXQT*p`jQ7=t:Bb !~ ݮJz>;7c&t-B0E;w6\QH$1.JZ1R|A.3Msaa!L:)뺍Fc0LLLPJ޽j25w/pܨ}669=MbhfLNwjQef6@;p]vE)MӃݻL4MuvVqױ'ڇˑI-x.D)}W*۷oW j-RM w:rk] *c]qNC.tA;pz!´Zr|pp0L"H%5u-dX\YYRf~# U[:BnY f #T4MӔ҃K.;(3 HqLZ% bP(?́zxC΄᱙ CwMMM (sk5h*d4f C<|<7 瞻p7okj`D`A TCqUe0b ru\ce6&PIL5B1ڽF>ąx<>H11_r} H E .UH)DBG?iMv8f]o>lfzfjr]7J-,,՟}Kz!\  q5Jŋ(j]-0–ɮ݌΋1,a.~^ӉFT*Hǎ] `R C J-FCCι#l۶(ҡ3ƄryeYBT*H$!eD"u1TaZ0$AwBd(cRNghօBa{{󼹹e4GFF\t:/_j(Pt̙p!U1<6vS3:BP(< Q(J&!rvbSN<MGUQq6{l( uaΩl6+LVU,٬iV*n+h4t:ɔJl6dDZpQH"ݤIU1Q"aW&T7M&j5s766ݮt:B)RA)W^aiO>˯آ.L؍@C_=!*3r\6-ˎ$c.D"D"a6TuB뺜shB @p BsI5844::cH,*vXEuCk6Mܹs ͈2٣W1EdztgXBث_;{0Rd2 !?߾/..D"vuuU(N.uTÜMAdIENDB`./docs/0000755000004100000410000000000013700622663012200 5ustar www-datawww-data./docs/reference/0000755000004100000410000000000013700622663014136 5ustar www-datawww-data./docs/reference/libappindicator-sections.txt0000644000004100000410000000254013700622663021671 0ustar www-datawww-data
app-indicator APP_INDICATOR_TYPE APP_INDICATOR APP_INDICATOR_CLASS IS_APP_INDICATOR IS_APP_INDICATOR_CLASS APP_INDICATOR_GET_CLASS APP_INDICATOR_SIGNAL_NEW_ICON APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON APP_INDICATOR_SIGNAL_NEW_STATUS APP_INDICATOR_SIGNAL_NEW_LABEL APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH APP_INDICATOR_SIGNAL_CONNECTION_CHANGED APP_INDICATOR_SIGNAL_SCROLL_EVENT AppIndicatorCategory AppIndicatorStatus AppIndicatorPrivate AppIndicator AppIndicator AppIndicatorClass app_indicator_get_type app_indicator_new app_indicator_new_with_path app_indicator_set_status app_indicator_set_attention_icon app_indicator_set_attention_icon_full app_indicator_set_menu app_indicator_set_icon app_indicator_set_icon_full app_indicator_set_icon_theme_path app_indicator_set_label app_indicator_set_ordering_index app_indicator_set_secondary_activate_target app_indicator_set_title app_indicator_get_id app_indicator_get_category app_indicator_get_status app_indicator_get_icon app_indicator_get_icon_desc app_indicator_get_icon_theme_path app_indicator_get_attention_icon app_indicator_get_attention_icon_desc app_indicator_get_menu app_indicator_get_label app_indicator_get_label_guide app_indicator_get_ordering_index app_indicator_get_secondary_activate_target app_indicator_get_title app_indicator_build_menu_from_desktop
./docs/reference/libappindicator-docs.sgml.in0000644000004100000410000000230413700622663021520 0ustar www-datawww-data ]> libappindicator Reference Manual for libappindicator @VERSION@ Base Classes for Applications Object Hierarchy API Index API 0.5 Index Deprecated API Index ./docs/reference/libappindicator.types0000644000004100000410000000002713700622663020367 0ustar www-datawww-dataapp_indicator_get_type ./docs/reference/version.xml.in0000644000004100000410000000001213700622663016743 0ustar www-datawww-data@VERSION@ ./docs/reference/Makefile.am0000644000004100000410000001006713700622663016176 0ustar www-datawww-data## Process this file with automake to produce Makefile.in # We require automake 1.6 at least. AUTOMAKE_OPTIONS = 1.6 if USE_GTK3 VER=3 APPINDICATORLIB = libappindicator3.la else VER= APPINDICATORLIB = libappindicator.la endif # This is a blank Makefile.am for using gtk-doc. # Copy this to your project's API docs directory and modify the variables to # suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples # of using the various options. # The name of the module, e.g. 'glib'. DOC_MODULE=libappindicator # Uncomment for versioned docs and specify the version of the module, e.g. '2'. #DOC_MODULE_VERSION=2 # 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). # gtk-doc will search all .c & .h files beneath here for inline comments # documenting the functions and macros. # e.g. DOC_SOURCE_DIR=../../../gtk DOC_SOURCE_DIR=$(top_srcdir)/src # Extra options to pass to gtkdoc-scangobj. Not normally needed. SCANGOBJ_OPTIONS=--type-init-func="g_type_init()" # Extra options to supply to gtkdoc-scan. # e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" #SCAN_OPTIONS=--rebuild-types --rebuild-sections SCAN_OPTIONS= # Extra options to supply to gtkdoc-mkdb. # e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml MKDB_OPTIONS=--sgml-mode --output-format=xml # Extra options to supply to gtkdoc-mktmpl # e.g. MKTMPL_OPTIONS=--only-section-tmpl MKTMPL_OPTIONS= # Extra options to supply to gtkdoc-mkhtml MKHTML_OPTIONS= # Extra options to supply to gtkdoc-fixref. Not normally needed. # e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html FIXXREF_OPTIONS= # Used for dependencies. The docs will be rebuilt if any of these change. # e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h # e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c HFILE_GLOB=$(top_srcdir)/src/app-indicator*.h CFILE_GLOB=$(top_srcdir)/src/app-indicator*.c # Header files to ignore when scanning. # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h IGNORE_HFILES= \ app-indicator-enum-types.h \ application-service-appstore.h \ application-service-client.h \ application-service-lru-file.h \ application-service-marshal.h \ application-service-server.h \ application-service-watcher.h \ dbus-properties-client.h \ dbus-properties-server.h \ dbus-shared.h \ generate-id.h \ notification-item-client.h \ notification-item-server.h \ notification-watcher-client.h \ notification-watcher-server.h # Images to copy into HTML directory. # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png HTML_IMAGES= # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). # e.g. content_files=running.sgml building.sgml changes-2.0.sgml content_files=version.xml # SGML files where gtk-doc abbrevations (#GtkWidget) are expanded # These files must be listed here *and* in content_files # e.g. expand_content_files=running.sgml expand_content_files= # CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. # Only needed if you are using gtkdoc-scangobj to dynamically query widget # signals and properties. # e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_srcdir)/src $(LIBRARY_CFLAGS) GTKDOC_LIBS=$(top_builddir)/src/$(APPINDICATORLIB) $(LIBRARY_LIBS) # 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 += version.xml.in libappindicator-docs.sgml.in # Files not to distribute # for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types # for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt #DISTCLEANFILES += # Comment this out if you want 'make check' to test you doc status # and run some sanity checks if ENABLE_GTK_DOC TESTS_ENVIRONMENT = cd $(srcdir) && \ DOC_MODULE=$(DOC_MODULE) DOC_MAIN_SGML_FILE=$(DOC_MAIN_SGML_FILE) \ SRCDIR=$(abs_srcdir) BUILDDIR=$(abs_builddir) #TESTS = $(GTKDOC_CHECK) endif ./docs/Makefile.am0000644000004100000410000000002413700622663014230 0ustar www-datawww-dataSUBDIRS = reference ./COPYING0000644000004100000410000001672713700622663012320 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. ./src/0000755000004100000410000000000013700622676012043 5ustar www-datawww-data./src/application-service-marshal.list0000644000004100000410000000162213700622663020323 0ustar www-datawww-data# Marshaller definitions to be generated. # # Copyright 2009 Canonical Ltd. # # Authors: # Ted Gould # # 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 warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, 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 . VOID: STRING, INT, STRING, STRING, STRING, STRING, STRING VOID: INT, STRING, STRING VOID: INT, STRING VOID: STRING, STRING VOID: BOOL, STRING, OBJECT VOID: INT, UINT VOID: INT, INT ./src/dbus-shared.h0000644000004100000410000000261713700622663014417 0ustar www-datawww-data/* DBus defaults for everyone to share in the project. Copyright 2009 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #define INDICATOR_APPLICATION_DBUS_ADDR "com.canonical.indicator.application" #define INDICATOR_APPLICATION_DBUS_OBJ "/com/canonical/indicator/application/service" #define INDICATOR_APPLICATION_DBUS_IFACE "com.canonical.indicator.application.service" #define NOTIFICATION_WATCHER_DBUS_ADDR "org.kde.StatusNotifierWatcher" #define NOTIFICATION_WATCHER_DBUS_OBJ "/StatusNotifierWatcher" #define NOTIFICATION_WATCHER_DBUS_IFACE "org.kde.StatusNotifierWatcher" #define NOTIFICATION_ITEM_DBUS_IFACE "org.kde.StatusNotifierItem" #define NOTIFICATION_ITEM_DEFAULT_OBJ "/StatusNotifierItem" #define NOTIFICATION_APPROVER_DBUS_IFACE "org.ayatana.StatusNotifierApprover" ./src/notification-item.xml0000644000004100000410000000357013700622663016210 0ustar www-datawww-data ./src/app-indicator-enum-types.h.in0000644000004100000410000000301613700622663017453 0ustar www-datawww-data/*** BEGIN file-header ***/ /* An object to represent the application as an application indicator in the system panel. Copyright 2009 Canonical Ltd. Authors: Ted Gould 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 */ #ifndef __APP_INDICATOR_ENUM_TYPES_H__ #define __APP_INDICATOR_ENUM_TYPES_H__ #include G_BEGIN_DECLS /*** END file-header ***/ /*** BEGIN file-tail ***/ G_END_DECLS #endif /* __APP_INDICATOR_ENUM_TYPES_H__ */ /*** END file-tail ***/ /*** BEGIN file-production ***/ /* Enumerations from file: "@basename@" */ /*** END file-production ***/ /*** BEGIN value-header ***/ GType @enum_name@_get_type (void) G_GNUC_CONST; #define APP_INDICATOR_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) /*** END value-header ***/ ./src/app-indicator.h0000644000004100000410000003515613700622663014754 0ustar www-datawww-data/* An object to represent the application as an application indicator in the system panel. Copyright 2009 Canonical Ltd. Authors: Ted Gould Cody Russell 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 */ #ifndef __APP_INDICATOR_H__ #define __APP_INDICATOR_H__ #include G_BEGIN_DECLS /** * APP_INDICATOR_TYPE: * * Get the #GType for a #AppIndicator. */ /** * APP_INDICATOR: * @obj: The object to convert * * Safely convert a #GObject into an #AppIndicator. */ /** * APP_INDICATOR_CLASS: * @klass: #GObjectClass based class to convert. * * Safely convert a #GObjectClass into a #AppIndicatorClass. */ /** * IS_APP_INDICATOR: * @obj: An #GObject to check * * Checks to see if @obj is in the object hierarchy of #AppIndicator. */ /** * IS_APP_INDICATOR_CLASS: * @klass: An #GObjectClass to check * * Checks to see if @klass is in the object class hierarchy of #AppIndicatorClass. */ /** * APP_INDICATOR_GET_CLASS: * @obj: A #GObject in the class hierarchy of #AppIndicator. * * Gets a pointer to the #AppIndicatorClass for the object @obj. */ #define APP_INDICATOR_TYPE (app_indicator_get_type ()) #define APP_INDICATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APP_INDICATOR_TYPE, AppIndicator)) #define APP_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APP_INDICATOR_TYPE, AppIndicatorClass)) #define IS_APP_INDICATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APP_INDICATOR_TYPE)) #define IS_APP_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APP_INDICATOR_TYPE)) #define APP_INDICATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APP_INDICATOR_TYPE, AppIndicatorClass)) /** * APP_INDICATOR_SIGNAL_NEW_ICON: * * String identifier for the #AppIndicator::new-icon signal. */ /** * APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON: * * String identifier for the #AppIndicator::new-attention-icon signal. */ /** * APP_INDICATOR_SIGNAL_NEW_STATUS: * * String identifier for the #AppIndicator::new-status signal. */ /** * APP_INDICATOR_SIGNAL_NEW_LABEL: * * String identifier for the #AppIndicator::new-label signal. */ /** * APP_INDICATOR_SIGNAL_CONNECTION_CHANGED: * * String identifier for the #AppIndicator::connection-changed signal. */ /** * APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH: * * String identifier for the #AppIndicator::new-icon-theme-path signal. */ /** * APP_INDICATOR_SIGNAL_SCROLL_EVENT: * * String identifier for the #AppIndicator::scroll-event signal. */ #define APP_INDICATOR_SIGNAL_NEW_ICON "new-icon" #define APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON "new-attention-icon" #define APP_INDICATOR_SIGNAL_NEW_STATUS "new-status" #define APP_INDICATOR_SIGNAL_NEW_LABEL "new-label" #define APP_INDICATOR_SIGNAL_CONNECTION_CHANGED "connection-changed" #define APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH "new-icon-theme-path" #define APP_INDICATOR_SIGNAL_SCROLL_EVENT "scroll-event" /** * AppIndicatorCategory: * @APP_INDICATOR_CATEGORY_APPLICATION_STATUS: The indicator is used to display the status of the application. * @APP_INDICATOR_CATEGORY_COMMUNICATIONS: The application is used for communication with other people. * @APP_INDICATOR_CATEGORY_SYSTEM_SERVICES: A system indicator relating to something in the user's system. * @APP_INDICATOR_CATEGORY_HARDWARE: An indicator relating to the user's hardware. * @APP_INDICATOR_CATEGORY_OTHER: Something not defined in this enum, please don't use unless you really need it. * * The category provides grouping for the indicators so that * users can find indicators that are similar together. */ typedef enum { /*< prefix=APP_INDICATOR_CATEGORY >*/ APP_INDICATOR_CATEGORY_APPLICATION_STATUS, /*< nick=ApplicationStatus >*/ APP_INDICATOR_CATEGORY_COMMUNICATIONS, /*< nick=Communications >*/ APP_INDICATOR_CATEGORY_SYSTEM_SERVICES, /*< nick=SystemServices >*/ APP_INDICATOR_CATEGORY_HARDWARE, /*< nick=Hardware >*/ APP_INDICATOR_CATEGORY_OTHER /*< nick=Other >*/ } AppIndicatorCategory; /** * AppIndicatorStatus: * @APP_INDICATOR_STATUS_PASSIVE: The indicator should not be shown to the user. * @APP_INDICATOR_STATUS_ACTIVE: The indicator should be shown in it's default state. * @APP_INDICATOR_STATUS_ATTENTION: The indicator should show it's attention icon. * * These are the states that the indicator can be on in * the user's panel. The indicator by default starts * in the state @APP_INDICATOR_STATUS_PASSIVE and can be * shown by setting it to @APP_INDICATOR_STATUS_ACTIVE. */ typedef enum { /*< prefix=APP_INDICATOR_STATUS >*/ APP_INDICATOR_STATUS_PASSIVE, /*< nick=Passive >*/ APP_INDICATOR_STATUS_ACTIVE, /*< nick=Active >*/ APP_INDICATOR_STATUS_ATTENTION /*< nick=NeedsAttention >*/ } AppIndicatorStatus; typedef struct _AppIndicator AppIndicator; typedef struct _AppIndicatorClass AppIndicatorClass; typedef struct _AppIndicatorPrivate AppIndicatorPrivate; /** * AppIndicatorClass: * @parent_class: Mia familia * @new_icon: Slot for #AppIndicator::new-icon. * @new_attention_icon: Slot for #AppIndicator::new-attention-icon. * @new_status: Slot for #AppIndicator::new-status. * @new_icon_theme_path: Slot for #AppIndicator::new-icon-theme-path * @new_label: Slot for #AppIndicator::new-label. * @connection_changed: Slot for #AppIndicator::connection-changed. * @scroll_event: Slot for #AppIndicator::scroll-event * @app_indicator_reserved_ats: Reserved for future use. * @fallback: Function that gets called to make a #GtkStatusIcon when * there is no Application Indicator area available. * @unfallback: The function that gets called if an Application * Indicator area appears after the fallback has been created. * @app_indicator_reserved_1: Reserved for future use. * @app_indicator_reserved_2: Reserved for future use. * @app_indicator_reserved_3: Reserved for future use. * @app_indicator_reserved_4: Reserved for future use. * @app_indicator_reserved_5: Reserved for future use. * @app_indicator_reserved_6: Reserved for future use. * * The signals and external functions that make up the #AppIndicator * class object. */ struct _AppIndicatorClass { /* Parent */ GObjectClass parent_class; /* DBus Signals */ void (* new_icon) (AppIndicator *indicator, gpointer user_data); void (* new_attention_icon) (AppIndicator *indicator, gpointer user_data); void (* new_status) (AppIndicator *indicator, const gchar *status, gpointer user_data); void (* new_icon_theme_path) (AppIndicator *indicator, const gchar *icon_theme_path, gpointer user_data); void (* new_label) (AppIndicator *indicator, const gchar *label, const gchar *guide, gpointer user_data); /* Local Signals */ void (* connection_changed) (AppIndicator * indicator, gboolean connected, gpointer user_data); void (* scroll_event) (AppIndicator * indicator, gint delta, GdkScrollDirection direction, gpointer user_data); void (*app_indicator_reserved_ats)(void); /* Overridable Functions */ GtkStatusIcon * (*fallback) (AppIndicator * indicator); void (*unfallback) (AppIndicator * indicator, GtkStatusIcon * status_icon); /* Reserved */ void (*app_indicator_reserved_1)(void); void (*app_indicator_reserved_2)(void); void (*app_indicator_reserved_3)(void); void (*app_indicator_reserved_4)(void); void (*app_indicator_reserved_5)(void); void (*app_indicator_reserved_6)(void); }; /** * AppIndicator: * * A application indicator represents the values that are needed to show a * unique status in the panel for an application. In general, applications * should try to fit in the other indicators that are available on the * panel before using this. But, sometimes it is necissary. * * Private fields * @parent: Parent object. * @priv: Internal data. */ struct _AppIndicator { GObject parent; /*< Private >*/ AppIndicatorPrivate *priv; }; /* GObject Stuff */ GType app_indicator_get_type (void) G_GNUC_CONST; AppIndicator *app_indicator_new (const gchar *id, const gchar *icon_name, AppIndicatorCategory category); AppIndicator *app_indicator_new_with_path (const gchar *id, const gchar *icon_name, AppIndicatorCategory category, const gchar *icon_theme_path); /* Set properties */ void app_indicator_set_status (AppIndicator *self, AppIndicatorStatus status); void app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name); void app_indicator_set_attention_icon_full (AppIndicator *self, const gchar *icon_name, const gchar *icon_desc); void app_indicator_set_menu (AppIndicator *self, GtkMenu *menu); void app_indicator_set_icon (AppIndicator *self, const gchar *icon_name); void app_indicator_set_icon_full (AppIndicator *self, const gchar *icon_name, const gchar *icon_desc); void app_indicator_set_label (AppIndicator *self, const gchar *label, const gchar *guide); void app_indicator_set_icon_theme_path(AppIndicator *self, const gchar *icon_theme_path); void app_indicator_set_ordering_index (AppIndicator *self, guint32 ordering_index); void app_indicator_set_secondary_activate_target (AppIndicator *self, GtkWidget *menuitem); void app_indicator_set_title (AppIndicator *self, const gchar *title); /* Get properties */ const gchar * app_indicator_get_id (AppIndicator *self); AppIndicatorCategory app_indicator_get_category (AppIndicator *self); AppIndicatorStatus app_indicator_get_status (AppIndicator *self); const gchar * app_indicator_get_icon (AppIndicator *self); const gchar * app_indicator_get_icon_desc (AppIndicator *self); const gchar * app_indicator_get_icon_theme_path (AppIndicator *self); const gchar * app_indicator_get_attention_icon (AppIndicator *self); const gchar * app_indicator_get_attention_icon_desc (AppIndicator *self); const gchar * app_indicator_get_title (AppIndicator *self); GtkMenu * app_indicator_get_menu (AppIndicator *self); const gchar * app_indicator_get_label (AppIndicator *self); const gchar * app_indicator_get_label_guide (AppIndicator *self); guint32 app_indicator_get_ordering_index (AppIndicator *self); GtkWidget * app_indicator_get_secondary_activate_target (AppIndicator *self); /* Helpers */ void app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file, const gchar * desktop_profile); G_END_DECLS /** * SECTION:app-indicator * @short_description: An object to put application information * into the panel. * @stability: Unstable * @include: libappindicator/app-indicator.h * * An application indicator is a way for an application to put * a menu into the panel on the user's screen. This allows the * user to interact with the application even though it might * not be visible to the user at the time. In most cases this * is not a good solution as there are other ways to inform the * user. It should only be use if persistence is a desired * feature for the user (not for your marketing purpose of * having your logo in the panel). */ #endif ./src/notification-watcher.xml0000644000004100000410000000173313700622663016706 0ustar www-datawww-data ./src/app-indicator-enum-types.c.in0000644000004100000410000000341313700622663017447 0ustar www-datawww-data/*** BEGIN file-header ***/ /* An object to represent the application as an application indicator in the system panel. Copyright 2009 Canonical Ltd. Authors: Ted Gould 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 */ #include "app-indicator-enum-types.h" /*** END file-header ***/ /*** BEGIN file-production ***/ #include "@basename@" /*** END file-production ***/ /*** BEGIN value-header ***/ /** @enum_name@_get_type: Builds a GLib type for the #@EnumName@ enumeration. Return value: A unique #GType for the #@EnumName@ enum. */ GType @enum_name@_get_type (void) { static GType etype = 0; if (G_UNLIKELY(etype == 0)) { static const G@Type@Value values[] = { /*** END value-header ***/ /*** BEGIN value-production ***/ { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, /*** END value-production ***/ /*** BEGIN value-tail ***/ { 0, NULL, NULL} }; etype = g_@type@_register_static (g_intern_static_string("@EnumName@"), values); } return etype; } /*** END value-tail ***/ ./src/indicator-desktop-shortcuts.c0000644000004100000410000005262313700622663017672 0ustar www-datawww-data/* A small file to parse through the actions that are available in the desktop file and making those easily usable. Copyright 2010 Canonical Ltd. Authors: Ted Gould This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation. 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 General Public License version 3.0 for more details. You should have received a copy of the GNU General Public License along with this library. If not, see . */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "indicator-desktop-shortcuts.h" #define ACTIONS_KEY "Actions" #define ACTION_GROUP_PREFIX "Desktop Action" #define OLD_GROUP_SUFFIX "Shortcut Group" #define OLD_SHORTCUTS_KEY "X-Ayatana-Desktop-Shortcuts" #define OLD_ENVIRON_KEY "TargetEnvironment" #define PROP_DESKTOP_FILE_S "desktop-file" #define PROP_IDENTITY_S "identity" typedef enum _actions_t actions_t; enum _actions_t { ACTIONS_NONE, ACTIONS_XAYATANA, ACTIONS_DESKTOP_SPEC }; typedef struct _IndicatorDesktopShortcutsPrivate IndicatorDesktopShortcutsPrivate; struct _IndicatorDesktopShortcutsPrivate { actions_t actions; GKeyFile * keyfile; gchar * identity; GArray * nicks; gchar * domain; }; enum { PROP_0, PROP_DESKTOP_FILE, PROP_IDENTITY }; #define INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_TYPE_DESKTOP_SHORTCUTS, IndicatorDesktopShortcutsPrivate)) static void indicator_desktop_shortcuts_class_init (IndicatorDesktopShortcutsClass *klass); static void indicator_desktop_shortcuts_init (IndicatorDesktopShortcuts *self); static void indicator_desktop_shortcuts_dispose (GObject *object); static void indicator_desktop_shortcuts_finalize (GObject *object); static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); static void parse_keyfile (IndicatorDesktopShortcuts * ids); static gboolean should_show (GKeyFile * keyfile, const gchar * group, const gchar * identity, gboolean should_have_target); G_DEFINE_TYPE (IndicatorDesktopShortcuts, indicator_desktop_shortcuts, G_TYPE_OBJECT); /* Build up the class */ static void indicator_desktop_shortcuts_class_init (IndicatorDesktopShortcutsClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (klass, sizeof (IndicatorDesktopShortcutsPrivate)); object_class->dispose = indicator_desktop_shortcuts_dispose; object_class->finalize = indicator_desktop_shortcuts_finalize; /* Property funcs */ object_class->set_property = set_property; object_class->get_property = get_property; g_object_class_install_property(object_class, PROP_DESKTOP_FILE, g_param_spec_string(PROP_DESKTOP_FILE_S, "The path of the desktop file to read", "A path to a desktop file that we'll look for shortcuts in.", NULL, G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property(object_class, PROP_IDENTITY, g_param_spec_string(PROP_IDENTITY_S, "The string that represents the identity that we're acting as.", "Used to process ShowIn and NotShownIn fields of the desktop shortcust to get the proper list.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); return; } /* Initialize instance data */ static void indicator_desktop_shortcuts_init (IndicatorDesktopShortcuts *self) { IndicatorDesktopShortcutsPrivate * priv = INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(self); priv->keyfile = NULL; priv->identity = NULL; priv->domain = NULL; priv->nicks = g_array_new(TRUE, TRUE, sizeof(gchar *)); priv->actions = ACTIONS_NONE; return; } /* Clear object references */ static void indicator_desktop_shortcuts_dispose (GObject *object) { IndicatorDesktopShortcutsPrivate * priv = INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(object); if (priv->keyfile) { g_key_file_free(priv->keyfile); priv->keyfile = NULL; } G_OBJECT_CLASS (indicator_desktop_shortcuts_parent_class)->dispose (object); return; } /* Free all memory */ static void indicator_desktop_shortcuts_finalize (GObject *object) { IndicatorDesktopShortcutsPrivate * priv = INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(object); if (priv->identity != NULL) { g_free(priv->identity); priv->identity = NULL; } if (priv->domain != NULL) { g_free(priv->domain); priv->domain = NULL; } if (priv->nicks != NULL) { gint i; for (i = 0; i < priv->nicks->len; i++) { gchar * nick = g_array_index(priv->nicks, gchar *, i); g_free(nick); } g_array_free(priv->nicks, TRUE); priv->nicks = NULL; } G_OBJECT_CLASS (indicator_desktop_shortcuts_parent_class)->finalize (object); return; } /* Sets one of the two properties we have, only at construction though */ static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { g_return_if_fail(INDICATOR_IS_DESKTOP_SHORTCUTS(object)); IndicatorDesktopShortcutsPrivate * priv = INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(object); switch(prop_id) { case PROP_DESKTOP_FILE: { if (priv->keyfile != NULL) { g_key_file_free(priv->keyfile); priv->keyfile = NULL; priv->actions = ACTIONS_NONE; } GError * error = NULL; GKeyFile * keyfile = g_key_file_new(); g_key_file_load_from_file(keyfile, g_value_get_string(value), G_KEY_FILE_NONE, &error); if (error != NULL) { g_warning("Unable to load keyfile from file '%s': %s", g_value_get_string(value), error->message); g_error_free(error); g_key_file_free(keyfile); break; } /* Always prefer the desktop spec if we can get it */ if (priv->actions == ACTIONS_NONE && g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, ACTIONS_KEY, NULL)) { priv->actions = ACTIONS_DESKTOP_SPEC; } /* But fallback if we can't */ if (priv->actions == ACTIONS_NONE && g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, OLD_SHORTCUTS_KEY, NULL)) { priv->actions = ACTIONS_XAYATANA; g_warning("Desktop file '%s' is using a deprecated format for its actions that will be dropped soon.", g_value_get_string(value)); } if (priv->actions == ACTIONS_NONE) { g_key_file_free(keyfile); break; } priv->keyfile = keyfile; parse_keyfile(INDICATOR_DESKTOP_SHORTCUTS(object)); break; } case PROP_IDENTITY: if (priv->identity != NULL) { g_warning("Identity already set to '%s' and trying to set it to '%s'.", priv->identity, g_value_get_string(value)); return; } priv->identity = g_value_dup_string(value); parse_keyfile(INDICATOR_DESKTOP_SHORTCUTS(object)); break; /* *********************** */ default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } return; } /* Gets either the desktop file our the identity. */ static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { g_return_if_fail(INDICATOR_IS_DESKTOP_SHORTCUTS(object)); IndicatorDesktopShortcutsPrivate * priv = INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(object); switch(prop_id) { case PROP_IDENTITY: g_value_set_string(value, priv->identity); break; /* *********************** */ default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } return; } /* Checks to see if we can, and if we can it goes through and parses the keyfile entries. */ static void parse_keyfile (IndicatorDesktopShortcuts * ids) { IndicatorDesktopShortcutsPrivate * priv = INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(ids); if (priv->keyfile == NULL) { return; } if (priv->identity == NULL) { return; } /* Remove a previous translation domain if we had one from a previously parsed file. */ if (priv->domain != NULL) { g_free(priv->domain); priv->domain = NULL; } /* Check to see if there is a custom translation domain that we should take into account. */ if (priv->domain == NULL && g_key_file_has_key(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-Gettext-Domain", NULL)) { priv->domain = g_key_file_get_string(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-Gettext-Domain", NULL); } if (priv->domain == NULL && g_key_file_has_key(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-Ubuntu-Gettext-Domain", NULL)) { priv->domain = g_key_file_get_string(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-Ubuntu-Gettext-Domain", NULL); } /* We need to figure out what we're looking for and what we want to look for in the rest of the file */ const gchar * list_name = NULL; const gchar * group_format = NULL; gboolean should_have_target = FALSE; switch (priv->actions) { case ACTIONS_NONE: /* None, let's just get outta here */ return; case ACTIONS_XAYATANA: list_name = OLD_SHORTCUTS_KEY; group_format = "%s " OLD_GROUP_SUFFIX; should_have_target = TRUE; break; case ACTIONS_DESKTOP_SPEC: list_name = ACTIONS_KEY; group_format = ACTION_GROUP_PREFIX " %s"; should_have_target = FALSE; break; default: g_assert_not_reached(); return; } /* Okay, we've got everything we need. Let's get it on! */ gint i; gsize num_nicks = 0; gchar ** nicks = g_key_file_get_string_list(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, list_name, &num_nicks, NULL); /* If there is an error from get_string_list num_nicks should still be zero, so this loop will drop out. */ for (i = 0; i < num_nicks; i++) { /* g_debug("Looking at group nick %s", nicks[i]); */ gchar * groupname = g_strdup_printf(group_format, nicks[i]); if (!g_key_file_has_group(priv->keyfile, groupname)) { g_warning("Unable to find group '%s'", groupname); g_free(groupname); continue; } if (!should_show(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, priv->identity, FALSE)) { g_free(groupname); continue; } if (!should_show(priv->keyfile, groupname, priv->identity, should_have_target)) { g_free(groupname); continue; } gchar * nickalloc = g_strdup(nicks[i]); g_array_append_val(priv->nicks, nickalloc); g_free(groupname); } if (nicks != NULL) { g_strfreev(nicks); } return; } /* Checks the ONLY_SHOW_IN and NOT_SHOW_IN keys for a group to see if we should be showing ourselves. */ static gboolean should_show (GKeyFile * keyfile, const gchar * group, const gchar * identity, gboolean should_have_target) { if (should_have_target && g_key_file_has_key(keyfile, group, OLD_ENVIRON_KEY, NULL)) { /* If we've got this key, we're going to return here and not process the deprecated keys. */ gint j; gsize num_env = 0; gchar ** envs = g_key_file_get_string_list(keyfile, group, OLD_ENVIRON_KEY, &num_env, NULL); for (j = 0; j < num_env; j++) { if (g_strcmp0(envs[j], identity) == 0) { break; } } if (envs != NULL) { g_strfreev(envs); } if (j == num_env) { return FALSE; } return TRUE; } /* If there is a list of OnlyShowIn entries we need to check to see if we're in that list. If not, we drop this nick */ if (g_key_file_has_key(keyfile, group, G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN, NULL)) { gint j; gsize num_only = 0; gchar ** onlies = g_key_file_get_string_list(keyfile, group, G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN, &num_only, NULL); for (j = 0; j < num_only; j++) { if (g_strcmp0(onlies[j], identity) == 0) { break; } } if (onlies != NULL) { g_strfreev(onlies); } if (j == num_only) { return FALSE; } } /* If there is a NotShowIn entry we need to make sure that we're not in that list. If we are, we need to drop out. */ if (g_key_file_has_key(keyfile, group, G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN, NULL)) { gint j; gsize num_not = 0; gchar ** nots = g_key_file_get_string_list(keyfile, group, G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN, &num_not, NULL); for (j = 0; j < num_not; j++) { if (g_strcmp0(nots[j], identity) == 0) { break; } } if (nots != NULL) { g_strfreev(nots); } if (j != num_not) { return FALSE; } } return TRUE; } /* Looks through the nicks to see if this one is in the list, and thus valid to use. */ static gboolean is_valid_nick (gchar ** list, const gchar * nick) { if (*list == NULL) return FALSE; /* g_debug("Checking Nick: %s", list[0]); */ if (g_strcmp0(list[0], nick) == 0) return TRUE; return is_valid_nick(&list[1], nick); } /* API */ /** indicator_desktop_shortcuts_new: @file: The desktop file that would be opened to find the actions. @identity: This is a string that represents the identity that should be used in searching those actions. It relates to the ShowIn and NotShownIn properties. This function creates the basic object. It involves opening the file and parsing it. It could potentially block on IO. At the end of the day you'll have a fully functional object. Return value: A new #IndicatorDesktopShortcuts object. */ IndicatorDesktopShortcuts * indicator_desktop_shortcuts_new (const gchar * file, const gchar * identity) { GObject * obj = g_object_new(INDICATOR_TYPE_DESKTOP_SHORTCUTS, PROP_DESKTOP_FILE_S, file, PROP_IDENTITY_S, identity, NULL); return INDICATOR_DESKTOP_SHORTCUTS(obj); } /** indicator_desktop_shortcuts_get_nicks: @ids: The #IndicatorDesktopShortcuts object to look in Give you the list of commands that are available for this desktop file given the identity that was passed in at creation. This will filter out the various items in the desktop file. These nicks can then be used as keys for working with the desktop file. Return value: A #NULL terminated list of strings. This memory is managed by the @ids object. */ const gchar ** indicator_desktop_shortcuts_get_nicks (IndicatorDesktopShortcuts * ids) { g_return_val_if_fail(INDICATOR_IS_DESKTOP_SHORTCUTS(ids), NULL); IndicatorDesktopShortcutsPrivate * priv = INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(ids); return (const gchar **)priv->nicks->data; } /** indicator_desktop_shortcuts_nick_get_name: @ids: The #IndicatorDesktopShortcuts object to look in @nick: Which command that we're referencing. This function looks in a desktop file for a nick to find the user visible name for that shortcut. The @nick parameter should be gotten from #indicator_desktop_shortcuts_get_nicks though it's not required that the exact memory location be the same. Return value: A user visible string for the shortcut or #NULL on error. */ gchar * indicator_desktop_shortcuts_nick_get_name (IndicatorDesktopShortcuts * ids, const gchar * nick) { g_return_val_if_fail(INDICATOR_IS_DESKTOP_SHORTCUTS(ids), NULL); IndicatorDesktopShortcutsPrivate * priv = INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(ids); g_return_val_if_fail(priv->actions != ACTIONS_NONE, NULL); g_return_val_if_fail(priv->keyfile != NULL, NULL); g_return_val_if_fail(is_valid_nick((gchar **)priv->nicks->data, nick), NULL); const gchar * group_format = NULL; switch (priv->actions) { case ACTIONS_XAYATANA: group_format = "%s " OLD_GROUP_SUFFIX; break; case ACTIONS_DESKTOP_SPEC: group_format = ACTION_GROUP_PREFIX " %s"; break; default: g_assert_not_reached(); return NULL; } gchar * groupheader = g_strdup_printf(group_format, nick); if (!g_key_file_has_group(priv->keyfile, groupheader)) { g_warning("The group for nick '%s' doesn't exist anymore.", nick); g_free(groupheader); return NULL; } if (!g_key_file_has_key(priv->keyfile, groupheader, G_KEY_FILE_DESKTOP_KEY_NAME, NULL)) { g_warning("No name available for nick '%s'", nick); g_free(groupheader); return NULL; } gchar * name = NULL; gchar * keyvalue = g_key_file_get_string(priv->keyfile, groupheader, G_KEY_FILE_DESKTOP_KEY_NAME, NULL); gchar * localeval = g_key_file_get_locale_string(priv->keyfile, groupheader, G_KEY_FILE_DESKTOP_KEY_NAME, NULL, NULL); g_free(groupheader); if (priv->domain != NULL && g_strcmp0(keyvalue, localeval) == 0) { name = g_strdup(g_dgettext(priv->domain, keyvalue)); g_free(localeval); } else { name = localeval; } g_free(keyvalue); return name; } /** indicator_desktop_shortcuts_nick_exec_with_context: @ids: The #IndicatorDesktopShortcuts object to look in @nick: Which command that we're referencing. @launch_context: The #GAppLaunchContext to use for launching the shortcut Here we take a @nick and try and execute the action that is associated with it. The @nick parameter should be gotten from #indicator_desktop_shortcuts_get_nicks though it's not required that the exact memory location be the same. Return value: #TRUE on success or #FALSE on error. */ gboolean indicator_desktop_shortcuts_nick_exec_with_context (IndicatorDesktopShortcuts * ids, const gchar * nick, GAppLaunchContext * launch_context) { GError * error = NULL; gchar * current_dir = NULL; g_return_val_if_fail(INDICATOR_IS_DESKTOP_SHORTCUTS(ids), FALSE); IndicatorDesktopShortcutsPrivate * priv = INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(ids); g_return_val_if_fail(priv->actions != ACTIONS_NONE, FALSE); g_return_val_if_fail(priv->keyfile != NULL, FALSE); g_return_val_if_fail(is_valid_nick((gchar **)priv->nicks->data, nick), FALSE); const gchar * group_format = NULL; switch (priv->actions) { case ACTIONS_XAYATANA: group_format = "%s " OLD_GROUP_SUFFIX; break; case ACTIONS_DESKTOP_SPEC: group_format = ACTION_GROUP_PREFIX " %s"; break; default: g_assert_not_reached(); return FALSE; } gchar * groupheader = g_strdup_printf(group_format, nick); if (!g_key_file_has_group(priv->keyfile, groupheader)) { g_warning("The group for nick '%s' doesn't exist anymore.", nick); g_free(groupheader); return FALSE; } if (!g_key_file_has_key(priv->keyfile, groupheader, G_KEY_FILE_DESKTOP_KEY_NAME, NULL)) { g_warning("No name available for nick '%s'", nick); g_free(groupheader); return FALSE; } if (!g_key_file_has_key(priv->keyfile, groupheader, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL)) { g_warning("No exec available for nick '%s'", nick); g_free(groupheader); return FALSE; } /* If possible move to the proper launch path */ gchar * path = g_key_file_get_string(priv->keyfile, groupheader, G_KEY_FILE_DESKTOP_KEY_PATH, NULL); if (path && *path != '\0') { current_dir = g_get_current_dir(); if (chdir(path) < 0) { g_warning("Impossible to run action '%s' from path '%s'", nick, path); g_free(current_dir); g_free(groupheader); g_free(path); return FALSE; } } /* Grab the name and the exec entries out of our current group */ gchar * name = g_key_file_get_locale_string(priv->keyfile, groupheader, G_KEY_FILE_DESKTOP_KEY_NAME, NULL, NULL); gchar * exec = g_key_file_get_locale_string(priv->keyfile, groupheader, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL, NULL); GAppInfoCreateFlags flags = G_APP_INFO_CREATE_NONE; if (launch_context) { flags |= G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION; } GAppInfo * appinfo = g_app_info_create_from_commandline(exec, name, flags, &error); g_free(groupheader); g_free(path); g_free(name); g_free(exec); if (error != NULL) { g_warning("Unable to build Command line App info: %s", error->message); g_free(current_dir); g_error_free(error); return FALSE; } if (appinfo == NULL) { g_warning("Unable to build Command line App info (unknown)"); g_free(current_dir); return FALSE; } gboolean launched = g_app_info_launch(appinfo, NULL, launch_context, &error); if (current_dir && chdir(current_dir) < 0) g_warning("Impossible to switch back to default work dir"); if (error != NULL) { g_warning("Unable to launch file from nick '%s': %s", nick, error->message); g_clear_error(&error); } g_free(current_dir); g_object_unref(appinfo); return launched; } /** indicator_desktop_shortcuts_nick_exec: @ids: The #IndicatorDesktopShortcuts object to look in @nick: Which command that we're referencing. Here we take a @nick and try and execute the action that is associated with it. The @nick parameter should be gotten from #indicator_desktop_shortcuts_get_nicks though it's not required that the exact memory location be the same. This function is deprecated and shouldn't be used in newly written code. Return value: #TRUE on success or #FALSE on error. */ gboolean indicator_desktop_shortcuts_nick_exec (IndicatorDesktopShortcuts * ids, const gchar * nick) { return indicator_desktop_shortcuts_nick_exec_with_context (ids, nick, NULL); } ./src/generate-id.h0000644000004100000410000000163013700622663014374 0ustar www-datawww-data/* Quick litte lack to generate the ordering ID. Copyright 2010 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #ifndef __GENERATE_ID_H__ #define __GENERATE_ID_H__ #include #include "app-indicator.h" guint32 _generate_id (const AppIndicatorCategory category, const gchar * id); #endif /* __GENERATE_ID_H__ */ ./src/appindicator-0.1.pc.in0000644000004100000410000000044513700622663015744 0ustar www-datawww-dataprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ Cflags: -I${includedir}/libappindicator-0.1 Requires: dbusmenu-glib-0.4 gtk+-2.0 Libs: -L${libdir} -lappindicator Name: appindicator-0.1 Description: Application indicators Version: @VERSION@ ./src/AppIndicator-0.1.metadata.in0000644000004100000410000000012713700622663017017 0ustar www-datawww-dataAppIndicator name="AppIndicator" Indicator.priv hidden="1" IndicatorPrivate hidden="1" ./src/indicator-desktop-shortcuts.h0000644000004100000410000000674613700622663017704 0ustar www-datawww-data/* A small file to parse through the actions that are available in the desktop file and making those easily usable. Copyright 2010 Canonical Ltd. Authors: Ted Gould This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation. 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 General Public License version 3.0 for more details. You should have received a copy of the GNU General Public License along with this library. If not, see . */ #ifndef __INDICATOR_DESKTOP_SHORTCUTS_H__ #define __INDICATOR_DESKTOP_SHORTCUTS_H__ #include #include #include G_BEGIN_DECLS #define INDICATOR_TYPE_DESKTOP_SHORTCUTS (indicator_desktop_shortcuts_get_type ()) #define INDICATOR_DESKTOP_SHORTCUTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_TYPE_DESKTOP_SHORTCUTS, IndicatorDesktopShortcuts)) #define INDICATOR_DESKTOP_SHORTCUTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_TYPE_DESKTOP_SHORTCUTS, IndicatorDesktopShortcutsClass)) #define INDICATOR_IS_DESKTOP_SHORTCUTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_TYPE_DESKTOP_SHORTCUTS)) #define INDICATOR_IS_DESKTOP_SHORTCUTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_TYPE_DESKTOP_SHORTCUTS)) #define INDICATOR_DESKTOP_SHORTCUTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_TYPE_DESKTOP_SHORTCUTS, IndicatorDesktopShortcutsClass)) typedef struct _IndicatorDesktopShortcuts IndicatorDesktopShortcuts; typedef struct _IndicatorDesktopShortcutsClass IndicatorDesktopShortcutsClass; /** IndicatorDesktopShortcutsClass: @parent_class: Space for #GObjectClass The vtable for our precious #IndicatorDesktopShortcutsClass. */ struct _IndicatorDesktopShortcutsClass { GObjectClass parent_class; }; /** IndicatorDesktopShortcuts: @parent: The parent data from #GObject The public data for an instance of the class #IndicatorDesktopShortcuts. */ struct _IndicatorDesktopShortcuts { GObject parent; }; GType indicator_desktop_shortcuts_get_type (void); IndicatorDesktopShortcuts * indicator_desktop_shortcuts_new (const gchar * file, const gchar * identity); const gchar ** indicator_desktop_shortcuts_get_nicks (IndicatorDesktopShortcuts * ids); gchar * indicator_desktop_shortcuts_nick_get_name (IndicatorDesktopShortcuts * ids, const gchar * nick); gboolean indicator_desktop_shortcuts_nick_exec_with_context (IndicatorDesktopShortcuts * ids, const gchar * nick, GAppLaunchContext * launch_context); GLIB_DEPRECATED_FOR(indicator_desktop_shortcuts_nick_exec_with_context) gboolean indicator_desktop_shortcuts_nick_exec (IndicatorDesktopShortcuts * ids, const gchar * nick); G_END_DECLS #endif ./src/appindicator3-0.1.pc.in0000644000004100000410000000045013700622663016023 0ustar www-datawww-dataprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ Cflags: -I${includedir}/libappindicator3-0.1 Requires: dbusmenu-glib-0.4 gtk+-3.0 Libs: -L${libdir} -lappindicator3 Name: appindicator3-0.1 Description: Application indicators Version: @VERSION@ ./src/AppIndicator3-0.1.metadata.in0000644000004100000410000000013013700622663017074 0ustar www-datawww-dataAppIndicator3 name="AppIndicator" Indicator.priv hidden="1" IndicatorPrivate hidden="1" ./src/generate-id.c0000644000004100000410000000321613700622663014371 0ustar www-datawww-data/* Quick litte lack to generate the ordering ID. Copyright 2010 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #include "generate-id.h" #define MULTIPLIER 32 guint32 _generate_id (const AppIndicatorCategory catenum, const gchar * id) { guchar category = 0; guchar first = 0; guchar second = 0; guchar third = 0; switch (catenum) { case APP_INDICATOR_CATEGORY_OTHER: category = MULTIPLIER * 5; break; case APP_INDICATOR_CATEGORY_APPLICATION_STATUS: category = MULTIPLIER * 4; break; case APP_INDICATOR_CATEGORY_COMMUNICATIONS: category = MULTIPLIER * 3; break; case APP_INDICATOR_CATEGORY_SYSTEM_SERVICES: category = MULTIPLIER * 2; break; case APP_INDICATOR_CATEGORY_HARDWARE: category = MULTIPLIER * 1; break; default: g_warning("Got an undefined category: %d", category); category = 0; break; } if (id != NULL) { if (id[0] != '\0') { first = id[0]; if (id[1] != '\0') { second = id[1]; if (id[2] != '\0') { third = id[2]; } } } } return (((((category << 8) + first) << 8) + second) << 8) + third; } ./src/Makefile.am0000644000004100000410000001164313700622663014100 0ustar www-datawww-dataif USE_GTK3 VER=3 lib_LTLIBRARIES = libappindicator3.la GTKGIR = Gtk-3.0 else VER= lib_LTLIBRARIES = libappindicator.la GTKGIR = Gtk-2.0 endif CLEANFILES = DISTCLEANFILES = BUILT_SOURCES = EXTRA_DIST = \ appindicator-0.1.pc.in \ appindicator3-0.1.pc.in \ AppIndicator-0.1.metadata.in \ AppIndicator3-0.1.metadata.in include $(top_srcdir)/Makefile.am.enum include $(top_srcdir)/Makefile.am.marshal ################################## # Marshallers ################################## BUILT_SOURCES += \ application-service-marshal.h \ application-service-marshal.c glib_marshal_list = application-service-marshal.list glib_marshal_prefix = _application_service_marshal ################################## # Library ################################## pkgconfig_DATA = appindicator$(VER)-0.1.pc pkgconfigdir = $(libdir)/pkgconfig glib_enum_h = app-indicator-enum-types.h glib_enum_c = app-indicator-enum-types.c glib_enum_headers = $(addprefix $(srcdir)/, $(libappindicator_headers)) DISTCLEANFILES += app-indicator-enum-types.c libappindicatorincludefolder=libappindicator libappindicatorincludedir=$(includedir)/libappindicator$(VER)-0.1/$(libappindicatorincludefolder) libappindicator_headers = \ app-indicator.h libappindicatorinclude_HEADERS = \ $(libappindicator_headers) \ $(glib_enum_h) libappindicator_la_SOURCES = \ $(libappindicator_headers) \ app-indicator-enum-types.c \ app-indicator.c \ application-service-marshal.c \ dbus-shared.h \ generate-id.h \ generate-id.c \ indicator-desktop-shortcuts.c \ indicator-desktop-shortcuts.h \ gen-notification-item.xml.h \ gen-notification-item.xml.c \ gen-notification-watcher.xml.h \ gen-notification-watcher.xml.c libappindicator_la_LDFLAGS = \ $(COVERAGE_LDFLAGS) \ -version-info 1:0:0 \ -no-undefined \ -export-symbols-regex "^app_indicator_.*" libappindicator_la_CFLAGS = \ $(LIBRARY_CFLAGS) \ $(COVERAGE_CFLAGS) \ -Wall -Wno-error=deprecated-declarations \ -DG_LOG_DOMAIN=\"libappindicator\" libappindicator_la_LIBADD = \ $(LIBRARY_LIBS) # We duplicate these here because Automake won't let us use $(VER) on the left hand side. # Since we carefully use $(VER) in the right hand side above, we can assign the same values. # Only one version of the library is every compiled at the same time, so it is safe to reuse # the right hand sides like this. libappindicator3includedir = $(libappindicatorincludedir) libappindicator3include_HEADERS = $(libappindicatorinclude_HEADERS) libappindicator3_la_SOURCES = $(libappindicator_la_SOURCES) libappindicator3_la_LDFLAGS = $(libappindicator_la_LDFLAGS) libappindicator3_la_CFLAGS = $(libappindicator_la_CFLAGS) libappindicator3_la_LIBADD = $(libappindicator_la_LIBADD) ################################## # DBus Specs ################################## DBUS_SPECS = \ notification-item.xml \ notification-watcher.xml gen-%.xml.h: %.xml @echo "Building $@ from $<" @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<))));" > $@ gen-%.xml.c: %.xml @echo "Building $@ from $<" @echo "const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<)))) = " > $@ @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@ @echo ";" >> $@ BUILT_SOURCES += \ gen-notification-item.xml.c \ gen-notification-item.xml.h \ gen-notification-watcher.xml.c \ gen-notification-watcher.xml.h CLEANFILES += \ gen-notification-item.xml.c \ gen-notification-item.xml.h \ gen-notification-watcher.xml.c \ gen-notification-watcher.xml.h EXTRA_DIST += $(DBUS_SPECS) ######################### # GObject Introsepction ######################### -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_GIRS = if INTROSPECTION_TEN INTROSPECTION_SCANNER_ARGS = \ --add-include-path=$(srcdir) \ $(addprefix --c-include=$(libappindicatorincludefolder)/, $(libappindicator_headers)) \ --symbol-prefix=app \ --identifier-prefix=App \ --warn-all else INTROSPECTION_SCANNER_ARGS = \ --add-include-path=$(srcdir) \ $(addprefix --c-include=$(libappindicatorincludefolder)/, $(libappindicator_headers)) endif INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir) if HAVE_INTROSPECTION introspection_sources = \ $(addprefix $(srcdir)/,app-indicator.c) \ $(addprefix $(srcdir)/,$(libappindicator_headers)) AppIndicator3-0.1.gir: libappindicator3.la AppIndicator3_0_1_gir_INCLUDES = \ GObject-2.0 \ $(GTKGIR) AppIndicator3_0_1_gir_CFLAGS = $(LIBRARY_CFLAGS) -I$(srcdir) -I$(top_builddir)/src AppIndicator3_0_1_gir_LIBS = libappindicator3.la AppIndicator3_0_1_gir_FILES = $(introspection_sources) # AppIndicator3_0_1_gir_NAMESPACE = AppIndicator INTROSPECTION_GIRS += AppIndicator3-0.1.gir AppIndicator3-0.1.metadata: AppIndicator3-0.1.gir cp -f $(srcdir)/$@.in $@ BUILT_SOURCES += AppIndicator3-0.1.metadata CLEANFILES += AppIndicator3-0.1.metadata girdir = $(datadir)/gir-1.0 gir_DATA = $(INTROSPECTION_GIRS) typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) CLEANFILES += $(gir_DATA) $(typelib_DATA) endif ./src/app-indicator.c0000644000004100000410000025051313700622676014747 0ustar www-datawww-data/* An object to represent the application as an application indicator in the system panel. Copyright 2009 Canonical Ltd. Authors: Ted Gould Cody Russell 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 */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include "indicator-desktop-shortcuts.h" #include #include "app-indicator.h" #include "app-indicator-enum-types.h" #include "application-service-marshal.h" #include "gen-notification-watcher.xml.h" #include "gen-notification-item.xml.h" #include "dbus-shared.h" #include "generate-id.h" #define PANEL_ICON_SUFFIX "panel" /** * AppIndicatorPrivate: * All of the private data in an instance of an application indicator. * * Private Fields * @id: The ID of the indicator. Maps to AppIndicator:id. * @category: Which category the indicator is. Maps to AppIndicator:category. * @status: The status of the indicator. Maps to AppIndicator:status. * @icon_name: The name of the icon to use. Maps to AppIndicator:icon-name. * @attention_icon_name: The name of the attention icon to use. Maps to AppIndicator:attention-icon-name. * @menu: The menu for this indicator. Maps to AppIndicator:menu * @watcher_proxy: The proxy connection to the watcher we're connected to. If we're not connected to one this will be %NULL. */ struct _AppIndicatorPrivate { /*< Private >*/ /* Properties */ gchar *id; gchar *clean_id; AppIndicatorCategory category; AppIndicatorStatus status; gchar *icon_name; gchar *absolute_icon_name; gchar *attention_icon_name; gchar *absolute_attention_icon_name; gchar *icon_theme_path; gchar *absolute_icon_theme_path; DbusmenuServer *menuservice; GtkWidget *menu; GtkWidget *sec_activate_target; gboolean sec_activate_enabled; guint32 ordering_index; gchar * title; gchar * label; gchar * label_guide; gchar * accessible_desc; gchar * att_accessible_desc; guint label_change_idle; GtkStatusIcon * status_icon; gint fallback_timer; /* Fun stuff */ GDBusConnection *connection; guint dbus_registration; gchar * path; /* StatusNotifierWatcher */ GDBusProxy *watcher_proxy; guint watcher_id; /* Might be used */ IndicatorDesktopShortcuts * shorties; }; /* Signals Stuff */ enum { NEW_ICON, NEW_ATTENTION_ICON, NEW_STATUS, NEW_LABEL, CONNECTION_CHANGED, NEW_ICON_THEME_PATH, SCROLL_EVENT, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; /* Enum for the properties so that they can be quickly found and looked up. */ enum { PROP_0, PROP_ID, PROP_CATEGORY, PROP_STATUS, PROP_ICON_NAME, PROP_ICON_DESC, PROP_ATTENTION_ICON_NAME, PROP_ATTENTION_ICON_DESC, PROP_ICON_THEME_PATH, PROP_CONNECTED, PROP_LABEL, PROP_LABEL_GUIDE, PROP_ORDERING_INDEX, PROP_DBUS_MENU_SERVER, PROP_TITLE }; /* The strings so that they can be slowly looked up. */ #define PROP_ID_S "id" #define PROP_CATEGORY_S "category" #define PROP_STATUS_S "status" #define PROP_ICON_NAME_S "icon-name" #define PROP_ICON_DESC_S "icon-desc" #define PROP_ATTENTION_ICON_NAME_S "attention-icon-name" #define PROP_ATTENTION_ICON_DESC_S "attention-icon-desc" #define PROP_ICON_THEME_PATH_S "icon-theme-path" #define PROP_CONNECTED_S "connected" #define PROP_LABEL_S "label" #define PROP_LABEL_GUIDE_S "label-guide" #define PROP_ORDERING_INDEX_S "ordering-index" #define PROP_DBUS_MENU_SERVER_S "dbus-menu-server" #define PROP_TITLE_S "title" /* Private macro, shhhh! */ #define APP_INDICATOR_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_INDICATOR_TYPE, AppIndicatorPrivate)) /* Default Path */ #define DEFAULT_ITEM_PATH "/org/ayatana/NotificationItem" /* More constants */ #define DEFAULT_FALLBACK_TIMER 100 /* in milliseconds */ /* Globals */ static GDBusNodeInfo * item_node_info = NULL; static GDBusInterfaceInfo * item_interface_info = NULL; static GDBusNodeInfo * watcher_node_info = NULL; static GDBusInterfaceInfo * watcher_interface_info = NULL; /* Boiler plate */ static void app_indicator_class_init (AppIndicatorClass *klass); static void app_indicator_init (AppIndicator *self); static void app_indicator_dispose (GObject *object); static void app_indicator_finalize (GObject *object); /* Property functions */ static void app_indicator_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); /* Other stuff */ static void signal_label_change (AppIndicator * self); static void check_connect (AppIndicator * self); static void register_service_cb (GObject * obj, GAsyncResult * res, gpointer user_data); static void start_fallback_timer (AppIndicator * self, gboolean disable_timeout); static gboolean fallback_timer_expire (gpointer data); static GtkStatusIcon * fallback (AppIndicator * self); static void status_icon_status_wrapper (AppIndicator * self, const gchar * status, gpointer data); static gboolean scroll_event_wrapper(GtkWidget *status_icon, GdkEventScroll *event, gpointer user_data); static gboolean middle_click_wrapper(GtkWidget *status_icon, GdkEventButton *event, gpointer user_data); static void status_icon_changes (AppIndicator * self, gpointer data); static void status_icon_activate (GtkStatusIcon * icon, gpointer data); static void status_icon_menu_activate (GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data); static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon); static gchar * append_panel_icon_suffix (const gchar * icon_name); static gchar * get_real_theme_path (AppIndicator * self); static gchar * append_snap_prefix (const gchar * path); static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data); static void sec_activate_target_parent_changed(GtkWidget *menuitem, GtkWidget *old_parent, gpointer user_data); static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data); static void bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data); static void bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data); static const GDBusInterfaceVTable item_interface_table = { method_call: bus_method_call, get_property: bus_get_prop, set_property: NULL /* No properties that can be set */ }; /* GObject type */ G_DEFINE_TYPE (AppIndicator, app_indicator, G_TYPE_OBJECT); static void check_is_host_registered (AppIndicator *self) { GVariant *variant; gboolean is_host_registered; variant = g_dbus_proxy_get_cached_property (self->priv->watcher_proxy, "IsStatusNotifierHostRegistered"); is_host_registered = FALSE; if (variant != NULL) { is_host_registered = g_variant_get_boolean (variant); g_variant_unref (variant); } if (!is_host_registered) { start_fallback_timer (self, FALSE); return; } check_connect (self); } static void watcher_properties_changed_cb (GDBusProxy *proxy, GVariant *changed_properties, GStrv invalidated_properties, AppIndicator *self) { check_is_host_registered (self); } static void watcher_ready_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { AppIndicator *self = (AppIndicator *) user_data; GError *error = NULL; self->priv->watcher_proxy = g_dbus_proxy_new_finish (res, &error); if (error) { start_fallback_timer (self, FALSE); g_object_unref (self); g_error_free (error); return; } g_signal_connect (self->priv->watcher_proxy, "g-properties-changed", G_CALLBACK (watcher_properties_changed_cb), self); check_is_host_registered (self); g_object_unref (self); } static void name_appeared_handler (GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data) { AppIndicator *self = (AppIndicator *) user_data; g_dbus_proxy_new (self->priv->connection, G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, watcher_interface_info, NOTIFICATION_WATCHER_DBUS_ADDR, NOTIFICATION_WATCHER_DBUS_OBJ, NOTIFICATION_WATCHER_DBUS_IFACE, NULL, (GAsyncReadyCallback) watcher_ready_cb, g_object_ref (self)); } static void name_vanished_handler (GDBusConnection *connection, const gchar *name, gpointer user_data) { AppIndicator *self = (AppIndicator *) user_data; g_clear_object (&self->priv->watcher_proxy); /* Emit the AppIndicator::connection-changed signal*/ g_signal_emit (self, signals[CONNECTION_CHANGED], 0, FALSE); start_fallback_timer (self, FALSE); } static void app_indicator_class_init (AppIndicatorClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); g_type_class_add_private (klass, sizeof (AppIndicatorPrivate)); /* Clean up */ object_class->dispose = app_indicator_dispose; object_class->finalize = app_indicator_finalize; /* Property funcs */ object_class->set_property = app_indicator_set_property; object_class->get_property = app_indicator_get_property; /* Our own funcs */ klass->fallback = fallback; klass->unfallback = unfallback; /* Properties */ /** * AppIndicator:id: * * The ID for this indicator, which should be unique, but used consistently * by this program and its indicator. */ g_object_class_install_property (object_class, PROP_ID, g_param_spec_string(PROP_ID_S, "The ID for this indicator", "An ID that should be unique, but used consistently by this program and its indicator.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); /** * AppIndicator:category: * * The type of indicator that this represents. Please don't use 'Other'. * Defaults to 'ApplicationStatus'. */ g_object_class_install_property (object_class, PROP_CATEGORY, g_param_spec_string (PROP_CATEGORY_S, "Indicator Category", "The type of indicator that this represents. Please don't use 'other'. Defaults to 'ApplicationStatus'.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); /** * AppIndicator:status: * * Whether the indicator is shown or requests attention. Defaults to * 'Passive'. */ g_object_class_install_property (object_class, PROP_STATUS, g_param_spec_string (PROP_STATUS_S, "Indicator Status", "Whether the indicator is shown or requests attention. Defaults to 'Passive'.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * AppIndicator:icon-name: * * The name of the regular icon that is shown for the indicator. */ g_object_class_install_property(object_class, PROP_ICON_NAME, g_param_spec_string (PROP_ICON_NAME_S, "An icon for the indicator", "The default icon that is shown for the indicator.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * AppIndicator:icon-desc: * * The description of the regular icon that is shown for the indicator. */ g_object_class_install_property(object_class, PROP_ICON_DESC, g_param_spec_string (PROP_ICON_DESC_S, "A description of the icon for the indicator", "A description of the default icon that is shown for the indicator.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * AppIndicator:attention-icon-name: * * If the indicator sets it's status to %APP_INDICATOR_STATUS_ATTENTION * then this icon is shown. */ g_object_class_install_property (object_class, PROP_ATTENTION_ICON_NAME, g_param_spec_string (PROP_ATTENTION_ICON_NAME_S, "An icon to show when the indicator request attention.", "If the indicator sets it's status to 'attention' then this icon is shown.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * AppIndicator:attention-icon-desc: * * If the indicator sets it's status to %APP_INDICATOR_STATUS_ATTENTION * then this textual description of the icon shown. */ g_object_class_install_property (object_class, PROP_ATTENTION_ICON_DESC, g_param_spec_string (PROP_ATTENTION_ICON_DESC_S, "A description of the icon to show when the indicator request attention.", "When the indicator is an attention mode this should describe the icon shown", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * AppIndicator:icon-theme-path: * * An additional place to look for icon names that may be installed by the * application. */ g_object_class_install_property(object_class, PROP_ICON_THEME_PATH, g_param_spec_string (PROP_ICON_THEME_PATH_S, "An additional path for custom icons.", "An additional place to look for icon names that may be installed by the application.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT)); /** * AppIndicator:connected: * * Pretty simple, %TRUE if we have a reasonable expectation of being * displayed through this object. You should hide your TrayIcon if so. */ g_object_class_install_property (object_class, PROP_CONNECTED, g_param_spec_boolean (PROP_CONNECTED_S, "Whether we're conneced to a watcher", "Pretty simple, true if we have a reasonable expectation of being displayed through this object. You should hide your TrayIcon if so.", FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /** * AppIndicator:label: * * A label that can be shown next to the string in the application * indicator. The label will not be shown unless there is an icon * as well. The label is useful for numerical and other frequently * updated information. In general, it shouldn't be shown unless a * user requests it as it can take up a significant amount of space * on the user's panel. This may not be shown in all visualizations. */ g_object_class_install_property(object_class, PROP_LABEL, g_param_spec_string (PROP_LABEL_S, "A label next to the icon", "A label to provide dynamic information.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * AppIndicator:label-guide: * * An optional string to provide guidance to the panel on how big * the #AppIndicator:label string could get. If this is set correctly * then the panel should never 'jiggle' as the string adjusts through * out the range of options. For instance, if you were providing a * percentage like "54% thrust" in #AppIndicator:label you'd want to * set this string to "100% thrust" to ensure space when Scotty can * get you enough power. */ g_object_class_install_property(object_class, PROP_LABEL_GUIDE, g_param_spec_string (PROP_LABEL_GUIDE_S, "A string to size the space available for the label.", "To ensure that the label does not cause the panel to 'jiggle' this string should provide information on how much space it could take.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * AppIndicator:ordering-index: * * The ordering index is an odd parameter, and if you think you don't need * it you're probably right. In general, the application indicator try * to place the applications in a recreatable place taking into account * which category they're in to try and group them. But, there are some * cases where you'd want to ensure indicators are next to each other. * To do that you can override the generated ordering index and replace it * with a new one. Again, you probably don't want to be doing this, but * in case you do, this is the way. */ g_object_class_install_property(object_class, PROP_ORDERING_INDEX, g_param_spec_uint (PROP_ORDERING_INDEX_S, "The location that this app indicator should be in the list.", "A way to override the default ordering of the applications by providing a very specific idea of where this entry should be placed.", 0, G_MAXUINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * AppIndicator:dbus-menu-server: * * A way to get the internal dbusmenu server if it is available. * This should only be used for testing. */ g_object_class_install_property(object_class, PROP_DBUS_MENU_SERVER, g_param_spec_object (PROP_DBUS_MENU_SERVER_S, "The internal DBusmenu Server", "DBusmenu server which is available for testing the application indicators.", DBUSMENU_TYPE_SERVER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * AppIndicator:title: * * Provides a way to refer to this application indicator in a human * readable form. This is used in the Unity desktop in the HUD as * the first part of the menu entries to distinguish them from the * focused application's entries. */ g_object_class_install_property(object_class, PROP_TITLE, g_param_spec_string (PROP_TITLE_S, "Title of the application indicator", "A human readable way to refer to this application indicator in the UI.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ /** * AppIndicator::new-icon: * @arg0: The #AppIndicator object * * when #AppIndicator:icon-name is changed */ signals[NEW_ICON] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_ICON, G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (AppIndicatorClass, new_icon), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); /** * AppIndicator::new-attention-icon: * @arg0: The #AppIndicator object * * Emitted when #AppIndicator:attention-icon-name is changed */ signals[NEW_ATTENTION_ICON] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON, G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (AppIndicatorClass, new_attention_icon), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); /** * AppIndicator::new-status: * @arg0: The #AppIndicator object * @arg1: The string value of the #AppIndicatorStatus enum. * * Emitted when #AppIndicator:status is changed */ signals[NEW_STATUS] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_STATUS, G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (AppIndicatorClass, new_status), NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); /** * AppIndicator::new-label: * @arg0: The #AppIndicator object * @arg1: The string for the label * @arg1: The string for the guide * * Emitted when either #AppIndicator:label or #AppIndicator:label-guide are * changed. */ signals[NEW_LABEL] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_LABEL, G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (AppIndicatorClass, new_label), NULL, NULL, _application_service_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); /** * AppIndicator::connection-changed: * @arg0: The #AppIndicator object * @arg1: Whether we're connected or not * * Signaled when we connect to a watcher, or when it drops away. */ signals[CONNECTION_CHANGED] = g_signal_new (APP_INDICATOR_SIGNAL_CONNECTION_CHANGED, G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (AppIndicatorClass, connection_changed), NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); /** * AppIndicator::new-icon-theme-path: * @arg0: The #AppIndicator object * * Signaled when there is a new icon set for the * object. */ signals[NEW_ICON_THEME_PATH] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_ICON_THEME_PATH, G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (AppIndicatorClass, new_icon_theme_path), NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); /** * AppIndicator::scroll-event: * @arg0: The #AppIndicator object * @arg1: How many steps the scroll wheel has taken * @arg2: (type Gdk.ScrollDirection): Which direction the wheel went in * * Signaled when the #AppIndicator receives a scroll event. */ signals[SCROLL_EVENT] = g_signal_new (APP_INDICATOR_SIGNAL_SCROLL_EVENT, G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (AppIndicatorClass, scroll_event), NULL, NULL, _application_service_marshal_VOID__INT_UINT, G_TYPE_NONE, 2, G_TYPE_INT, GDK_TYPE_SCROLL_DIRECTION); /* DBus interfaces */ if (item_node_info == NULL) { GError * error = NULL; item_node_info = g_dbus_node_info_new_for_xml(_notification_item, &error); if (error != NULL) { g_error("Unable to parse Notification Item DBus interface: %s", error->message); g_error_free(error); } } if (item_interface_info == NULL && item_node_info != NULL) { item_interface_info = g_dbus_node_info_lookup_interface(item_node_info, NOTIFICATION_ITEM_DBUS_IFACE); if (item_interface_info == NULL) { g_error("Unable to find interface '" NOTIFICATION_ITEM_DBUS_IFACE "'"); } } if (watcher_node_info == NULL) { GError * error = NULL; watcher_node_info = g_dbus_node_info_new_for_xml(_notification_watcher, &error); if (error != NULL) { g_error("Unable to parse Notification Item DBus interface: %s", error->message); g_error_free(error); } } if (watcher_interface_info == NULL && watcher_node_info != NULL) { watcher_interface_info = g_dbus_node_info_lookup_interface(watcher_node_info, NOTIFICATION_WATCHER_DBUS_IFACE); if (watcher_interface_info == NULL) { g_error("Unable to find interface '" NOTIFICATION_WATCHER_DBUS_IFACE "'"); } } return; } static void app_indicator_init (AppIndicator *self) { AppIndicatorPrivate * priv = APP_INDICATOR_GET_PRIVATE(self); self->priv = priv; priv->id = NULL; priv->clean_id = NULL; priv->category = APP_INDICATOR_CATEGORY_OTHER; priv->status = APP_INDICATOR_STATUS_PASSIVE; priv->icon_name = NULL; priv->attention_icon_name = NULL; priv->icon_theme_path = NULL; priv->absolute_icon_theme_path = get_real_theme_path (self); priv->menu = NULL; priv->menuservice = NULL; priv->ordering_index = 0; priv->title = NULL; priv->label = NULL; priv->label_guide = NULL; priv->label_change_idle = 0; priv->connection = NULL; priv->dbus_registration = 0; priv->path = NULL; priv->status_icon = NULL; priv->fallback_timer = 0; priv->shorties = NULL; priv->sec_activate_target = NULL; priv->sec_activate_enabled = FALSE; priv->watcher_proxy = NULL; priv->watcher_id = g_bus_watch_name (G_BUS_TYPE_SESSION, NOTIFICATION_WATCHER_DBUS_ADDR, G_BUS_NAME_WATCHER_FLAGS_NONE, (GBusNameAppearedCallback) name_appeared_handler, (GBusNameVanishedCallback) name_vanished_handler, self, NULL); /* Start getting the session bus */ g_object_ref(self); /* ref for the bus creation callback */ g_bus_get(G_BUS_TYPE_SESSION, NULL, bus_creation, self); g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), "changed", G_CALLBACK(theme_changed_cb), self); return; } /* Free all objects, make sure that all the dbus signals are sent out before we shut this down. */ static void app_indicator_dispose (GObject *object) { AppIndicator *self = APP_INDICATOR (object); AppIndicatorPrivate *priv = self->priv; if (priv->shorties != NULL) { g_object_unref(G_OBJECT(priv->shorties)); priv->shorties = NULL; } if (priv->status != APP_INDICATOR_STATUS_PASSIVE) { app_indicator_set_status(self, APP_INDICATOR_STATUS_PASSIVE); } if (priv->status_icon != NULL) { AppIndicatorClass * class = APP_INDICATOR_GET_CLASS(object); if (class->unfallback != NULL) { class->unfallback(self, priv->status_icon); } priv->status_icon = NULL; } if (priv->fallback_timer != 0) { g_source_remove(priv->fallback_timer); priv->fallback_timer = 0; } if (priv->label_change_idle != 0) { g_source_remove(priv->label_change_idle); priv->label_change_idle = 0; } if (priv->menu != NULL) { g_object_unref(G_OBJECT(priv->menu)); priv->menu = NULL; } if (priv->menuservice != NULL) { g_object_unref (priv->menuservice); } if (priv->watcher_id != 0) { g_bus_unwatch_name (priv->watcher_id); priv->watcher_id = 0; } if (priv->watcher_proxy != NULL) { g_object_unref(G_OBJECT(priv->watcher_proxy)); priv->watcher_proxy = NULL; /* Emit the AppIndicator::connection-changed signal*/ g_signal_emit (self, signals[CONNECTION_CHANGED], 0, FALSE); } if (priv->dbus_registration != 0) { g_dbus_connection_unregister_object(priv->connection, priv->dbus_registration); priv->dbus_registration = 0; } if (priv->connection != NULL) { g_object_unref(G_OBJECT(priv->connection)); priv->connection = NULL; } if (priv->sec_activate_target != NULL) { g_signal_handlers_disconnect_by_func (priv->sec_activate_target, sec_activate_target_parent_changed, self); g_object_unref(G_OBJECT(priv->sec_activate_target)); priv->sec_activate_target = NULL; } g_signal_handlers_disconnect_by_func(gtk_icon_theme_get_default(), G_CALLBACK(theme_changed_cb), self); G_OBJECT_CLASS (app_indicator_parent_class)->dispose (object); return; } /* Free all of the memory that we could be using in the object. */ static void app_indicator_finalize (GObject *object) { AppIndicator * self = APP_INDICATOR(object); AppIndicatorPrivate *priv = self->priv; if (priv->status != APP_INDICATOR_STATUS_PASSIVE) { g_warning("Finalizing Application Status with the status set to: %d", priv->status); } if (priv->id != NULL) { g_free(priv->id); priv->id = NULL; } if (priv->clean_id != NULL) { g_free(priv->clean_id); priv->clean_id = NULL; } if (priv->icon_name != NULL) { g_free(priv->icon_name); priv->icon_name = NULL; } if (priv->absolute_icon_name != NULL) { g_free(priv->absolute_icon_name); priv->absolute_icon_name = NULL; } if (priv->attention_icon_name != NULL) { g_free(priv->attention_icon_name); priv->attention_icon_name = NULL; } if (priv->absolute_attention_icon_name != NULL) { g_free(priv->absolute_attention_icon_name); priv->absolute_attention_icon_name = NULL; } if (priv->icon_theme_path != NULL) { g_free(priv->icon_theme_path); priv->icon_theme_path = NULL; } if (priv->absolute_icon_theme_path != NULL) { g_free(priv->absolute_icon_theme_path); priv->absolute_icon_theme_path = NULL; } if (priv->title != NULL) { g_free(priv->title); priv->title = NULL; } if (priv->label != NULL) { g_free(priv->label); priv->label = NULL; } if (priv->label_guide != NULL) { g_free(priv->label_guide); priv->label_guide = NULL; } if (priv->accessible_desc != NULL) { g_free(priv->accessible_desc); priv->accessible_desc = NULL; } if (priv->att_accessible_desc != NULL) { g_free(priv->att_accessible_desc); priv->att_accessible_desc = NULL; } if (priv->path != NULL) { g_free(priv->path); priv->path = NULL; } G_OBJECT_CLASS (app_indicator_parent_class)->finalize (object); return; } #define WARN_BAD_TYPE(prop, value) g_warning("Can not work with property '%s' with value of type '%s'.", prop, G_VALUE_TYPE_NAME(value)) /* Set some properties */ static void app_indicator_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { AppIndicator *self = APP_INDICATOR (object); AppIndicatorPrivate *priv = self->priv; GEnumValue *enum_val; switch (prop_id) { case PROP_ID: if (priv->id != NULL) { g_warning ("Resetting ID value when I already had a value of: %s", priv->id); break; } priv->id = g_strdup (g_value_get_string (value)); priv->clean_id = g_strdup(priv->id); gchar * cleaner; for (cleaner = priv->clean_id; *cleaner != '\0'; cleaner++) { if (!g_ascii_isalnum(*cleaner)) { *cleaner = '_'; } } check_connect (self); break; case PROP_CATEGORY: enum_val = g_enum_get_value_by_nick ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_CATEGORY), g_value_get_string (value)); if (priv->category != enum_val->value) { priv->category = enum_val->value; } break; case PROP_STATUS: enum_val = g_enum_get_value_by_nick ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), g_value_get_string (value)); app_indicator_set_status (APP_INDICATOR (object), enum_val->value); break; case PROP_ICON_NAME: app_indicator_set_icon_full (APP_INDICATOR (object), g_value_get_string (value), priv->accessible_desc); check_connect (self); break; case PROP_ICON_DESC: app_indicator_set_icon_full (APP_INDICATOR (object), priv->icon_name, g_value_get_string (value)); check_connect (self); break; case PROP_ATTENTION_ICON_NAME: app_indicator_set_attention_icon_full (APP_INDICATOR (object), g_value_get_string (value), priv->att_accessible_desc); break; case PROP_ATTENTION_ICON_DESC: app_indicator_set_attention_icon_full (APP_INDICATOR (object), priv->attention_icon_name, g_value_get_string (value)); break; case PROP_ICON_THEME_PATH: app_indicator_set_icon_theme_path (APP_INDICATOR (object), g_value_get_string (value)); check_connect (self); break; case PROP_LABEL: { gchar * oldlabel = priv->label; priv->label = g_value_dup_string(value); if (priv->label != NULL && priv->label[0] == '\0') { g_free(priv->label); priv->label = NULL; } if (g_strcmp0(oldlabel, priv->label) != 0) { signal_label_change(APP_INDICATOR(object)); } if (oldlabel != NULL) { g_free(oldlabel); } break; } case PROP_TITLE: { gchar * oldtitle = priv->title; priv->title = g_value_dup_string(value); if (priv->title != NULL && priv->title[0] == '\0') { g_free(priv->title); priv->title = NULL; } if (g_strcmp0(oldtitle, priv->title) != 0 && self->priv->connection != NULL) { GError * error = NULL; g_dbus_connection_emit_signal(self->priv->connection, NULL, self->priv->path, NOTIFICATION_ITEM_DBUS_IFACE, "NewTitle", NULL, &error); if (error != NULL) { g_warning("Unable to send signal for NewTitle: %s", error->message); g_error_free(error); } } if (oldtitle != NULL) { g_free(oldtitle); } if (priv->status_icon != NULL) { gtk_status_icon_set_title(priv->status_icon, priv->title ? priv->title : ""); } break; } case PROP_LABEL_GUIDE: { gchar * oldguide = priv->label_guide; priv->label_guide = g_value_dup_string(value); if (priv->label_guide != NULL && priv->label_guide[0] == '\0') { g_free(priv->label_guide); priv->label_guide = NULL; } if (g_strcmp0(oldguide, priv->label_guide) != 0) { signal_label_change(APP_INDICATOR(object)); } if (priv->label_guide != NULL && priv->label_guide[0] == '\0') { g_free(priv->label_guide); priv->label_guide = NULL; } if (oldguide != NULL) { g_free(oldguide); } break; } case PROP_ORDERING_INDEX: priv->ordering_index = g_value_get_uint(value); break; case PROP_DBUS_MENU_SERVER: g_clear_object (&priv->menuservice); priv->menuservice = DBUSMENU_SERVER (g_value_dup_object(value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } return; } /* Function to fill our value with the property it's requesting. */ static void app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { AppIndicator *self = APP_INDICATOR (object); AppIndicatorPrivate *priv = self->priv; GEnumValue *enum_value; switch (prop_id) { case PROP_ID: g_value_set_string (value, priv->id); break; case PROP_CATEGORY: enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_CATEGORY), priv->category); g_value_set_string (value, enum_value->value_nick); break; case PROP_STATUS: enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), priv->status); g_value_set_string (value, enum_value->value_nick); break; case PROP_ICON_NAME: g_value_set_string (value, priv->icon_name); break; case PROP_ICON_DESC: g_value_set_string (value, priv->accessible_desc); break; case PROP_ATTENTION_ICON_NAME: g_value_set_string (value, priv->attention_icon_name); break; case PROP_ATTENTION_ICON_DESC: g_value_set_string (value, priv->att_accessible_desc); break; case PROP_ICON_THEME_PATH: g_value_set_string (value, priv->icon_theme_path); break; case PROP_CONNECTED: { gboolean connected = FALSE; if (priv->watcher_proxy != NULL) { gchar * name = g_dbus_proxy_get_name_owner(priv->watcher_proxy); if (name != NULL) { connected = TRUE; g_free(name); } } g_value_set_boolean (value, connected); break; } case PROP_LABEL: g_value_set_string (value, priv->label); break; case PROP_LABEL_GUIDE: g_value_set_string (value, priv->label_guide); break; case PROP_ORDERING_INDEX: g_value_set_uint(value, priv->ordering_index); break; case PROP_DBUS_MENU_SERVER: g_value_set_object(value, priv->menuservice); break; case PROP_TITLE: g_value_set_string(value, priv->title); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } return; } /* DBus bus has been created, well maybe, but we got a call back about it so we need to check into it. */ static void bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data) { GError * error = NULL; GDBusConnection * connection = g_bus_get_finish(res, &error); if (error != NULL) { g_warning("Unable to get the session bus: %s", error->message); g_error_free(error); g_object_unref(G_OBJECT(user_data)); return; } AppIndicator * app = APP_INDICATOR(user_data); app->priv->connection = connection; /* If the connection was blocking the exporting of the object this function will export everything. */ check_connect(app); g_object_unref(G_OBJECT(app)); return; } static void bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data) { g_return_if_fail(IS_APP_INDICATOR(user_data)); AppIndicator * app = APP_INDICATOR(user_data); AppIndicatorPrivate * priv = app->priv; GVariant * retval = NULL; if (g_strcmp0(method, "Scroll") == 0) { GdkScrollDirection direction; gint delta; const gchar *orientation; g_variant_get(params, "(i&s)", &delta, &orientation); if (g_strcmp0(orientation, "horizontal") == 0) { direction = (delta >= 0) ? GDK_SCROLL_RIGHT : GDK_SCROLL_LEFT; } else if (g_strcmp0(orientation, "vertical") == 0) { direction = (delta >= 0) ? GDK_SCROLL_DOWN : GDK_SCROLL_UP; } else { g_dbus_method_invocation_return_value(invocation, retval); return; } delta = ABS(delta); g_signal_emit(app, signals[SCROLL_EVENT], 0, delta, direction); } else if (g_strcmp0(method, "SecondaryActivate") == 0 || g_strcmp0(method, "XAyatanaSecondaryActivate") == 0) { GtkWidget *menuitem = priv->sec_activate_target; if (priv->sec_activate_enabled && menuitem && gtk_widget_get_visible (menuitem) && gtk_widget_get_sensitive (menuitem)) { gtk_widget_activate (menuitem); } } else { g_warning("Calling method '%s' on the app-indicator and it's unknown", method); } g_dbus_method_invocation_return_value(invocation, retval); } /* DBus is asking for a property so we should figure out what it wants and try and deliver. */ static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data) { g_return_val_if_fail(IS_APP_INDICATOR(user_data), NULL); AppIndicator * app = APP_INDICATOR(user_data); AppIndicatorPrivate *priv = app->priv; if (g_strcmp0(property, "Id") == 0) { return g_variant_new_string(app->priv->id ? app->priv->id : ""); } else if (g_strcmp0(property, "Category") == 0) { GEnumValue *enum_value; enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_CATEGORY), priv->category); return g_variant_new_string(enum_value->value_nick ? enum_value->value_nick : ""); } else if (g_strcmp0(property, "Status") == 0) { GEnumValue *enum_value; enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), priv->status); return g_variant_new_string(enum_value->value_nick ? enum_value->value_nick : ""); } else if (g_strcmp0(property, "IconName") == 0) { if (priv->absolute_icon_name) { return g_variant_new_string(priv->absolute_icon_name); } return g_variant_new_string(priv->icon_name ? priv->icon_name : ""); } else if (g_strcmp0(property, "AttentionIconName") == 0) { if (priv->absolute_attention_icon_name) { return g_variant_new_string(priv->absolute_attention_icon_name); } return g_variant_new_string(priv->attention_icon_name ? priv->attention_icon_name : ""); } else if (g_strcmp0(property, "Title") == 0) { const gchar * output = NULL; if (priv->title == NULL) { const gchar * name = g_get_application_name(); if (name != NULL) { output = name; } else { output = ""; } } else { output = priv->title; } return g_variant_new_string(output); } else if (g_strcmp0(property, "IconThemePath") == 0) { if (priv->absolute_icon_theme_path) { return g_variant_new_string(priv->absolute_icon_theme_path); } return g_variant_new_string(priv->icon_theme_path ? priv->icon_theme_path : ""); } else if (g_strcmp0(property, "Menu") == 0) { if (priv->menuservice != NULL) { GValue strval = { 0 }; g_value_init(&strval, G_TYPE_STRING); g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strval); GVariant * var = g_variant_new("o", g_value_get_string(&strval)); g_value_unset(&strval); return var; } else { return g_variant_new("o", "/"); } } else if (g_strcmp0(property, "XAyatanaLabel") == 0) { return g_variant_new_string(priv->label ? priv->label : ""); } else if (g_strcmp0(property, "XAyatanaLabelGuide") == 0) { return g_variant_new_string(priv->label_guide ? priv->label_guide : ""); } else if (g_strcmp0(property, "XAyatanaOrderingIndex") == 0) { return g_variant_new_uint32(priv->ordering_index); } else if (g_strcmp0(property, "IconAccessibleDesc") == 0) { return g_variant_new_string(priv->accessible_desc ? priv->accessible_desc : ""); } else if (g_strcmp0(property, "AttentionAccessibleDesc") == 0) { return g_variant_new_string(priv->att_accessible_desc ? priv->att_accessible_desc : ""); } *error = g_error_new(0, 0, "Unknown property: %s", property); return NULL; } /* Sends the label changed signal and resets the source ID */ static gboolean signal_label_change_idle (gpointer user_data) { AppIndicator * self = (AppIndicator *)user_data; AppIndicatorPrivate *priv = self->priv; gchar * label = priv->label != NULL ? priv->label : ""; gchar * guide = priv->label_guide != NULL ? priv->label_guide : ""; g_signal_emit(G_OBJECT(self), signals[NEW_LABEL], 0, label, guide); if (priv->dbus_registration != 0 && priv->connection != NULL) { GError * error = NULL; g_dbus_connection_emit_signal(priv->connection, NULL, priv->path, NOTIFICATION_ITEM_DBUS_IFACE, "XAyatanaNewLabel", g_variant_new("(ss)", label, guide), &error); if (error != NULL) { g_warning("Unable to send signal for NewIcon: %s", error->message); g_error_free(error); } } priv->label_change_idle = 0; return FALSE; } /* Sets up an idle function to send the label changed signal so that we don't send it too many times. */ static void signal_label_change (AppIndicator * self) { AppIndicatorPrivate *priv = self->priv; /* don't set it twice */ if (priv->label_change_idle != 0) { return; } priv->label_change_idle = g_idle_add(signal_label_change_idle, self); return; } /* This function is used to see if we have enough information to connect to things. If we do, and we're not connected, it connects for us. */ static void check_connect (AppIndicator *self) { AppIndicatorPrivate *priv = self->priv; /* Do we have a connection? */ if (priv->connection == NULL) return; /* If we already have a proxy, let's see if it has someone implementing it. If not, we can't do much more than to do nothing. */ if (priv->watcher_proxy != NULL) { gchar * name = g_dbus_proxy_get_name_owner(priv->watcher_proxy); if (name == NULL) { return; } g_free(name); } /* Do we have enough information? */ if (priv->menu == NULL) return; if (priv->icon_name == NULL) return; if (priv->id == NULL) return; if (priv->path == NULL) { priv->path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s", priv->clean_id); } if (priv->dbus_registration == 0) { GError * error = NULL; priv->dbus_registration = g_dbus_connection_register_object(priv->connection, priv->path, item_interface_info, &item_interface_table, self, NULL, &error); if (error != NULL) { g_warning("Unable to register object on path '%s': %s", priv->path, error->message); g_error_free(error); return; } } /* NOTE: It's really important the order here. We make sure to *publish* the object on the bus and *then* get the proxy. The reason is that we want to ensure all the filters are setup before talking to the watcher and that's where the order is important. */ if (priv->watcher_proxy == NULL) return; g_dbus_proxy_call (priv->watcher_proxy, "RegisterStatusNotifierItem", g_variant_new ("(s)", priv->path), G_DBUS_CALL_FLAGS_NONE, -1, NULL, (GAsyncReadyCallback) register_service_cb, g_object_ref (self)); } /* Responce from the DBus command to register a service with a NotificationWatcher. */ static void register_service_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { GError * error = NULL; GVariant * returns = g_dbus_proxy_call_finish(G_DBUS_PROXY(obj), res, &error); /* We don't care about any return values */ if (returns != NULL) { g_variant_unref(returns); } if (error != NULL) { /* They didn't respond, ewww. Not sure what they could be doing */ g_warning("Unable to connect to the Notification Watcher: %s", error->message); start_fallback_timer(APP_INDICATOR(user_data), TRUE); g_object_unref(G_OBJECT(user_data)); return; } g_return_if_fail(IS_APP_INDICATOR(user_data)); AppIndicator * app = APP_INDICATOR(user_data); AppIndicatorPrivate * priv = app->priv; /* Emit the AppIndicator::connection-changed signal*/ g_signal_emit (app, signals[CONNECTION_CHANGED], 0, TRUE); if (priv->status_icon) { AppIndicatorClass * class = APP_INDICATOR_GET_CLASS(app); if (class->unfallback != NULL) { class->unfallback(app, priv->status_icon); priv->status_icon = NULL; } } g_object_unref(G_OBJECT(user_data)); return; } /* A helper function to get the nick out of a given category enum value. */ static const gchar * category_from_enum (AppIndicatorCategory category) { GEnumValue *value; value = g_enum_get_value ((GEnumClass *)g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_CATEGORY), category); return value->value_nick; } /* A function that will start the fallback timer if it's not already started. It sets up the DBus watcher to see if there is a change. Also, provides an override mode for cases where it's unlikely that a timer will help anything. */ static void start_fallback_timer (AppIndicator * self, gboolean disable_timeout) { g_return_if_fail(IS_APP_INDICATOR(self)); AppIndicatorPrivate * priv = APP_INDICATOR(self)->priv; if (priv->fallback_timer != 0) { /* The timer is set, let's just be happy with the one we've already got running */ return; } if (priv->status_icon != NULL) { /* We're already fallen back. Let's not do it again. */ return; } if (disable_timeout) { fallback_timer_expire(self); } else { priv->fallback_timer = g_timeout_add(DEFAULT_FALLBACK_TIMER, fallback_timer_expire, self); } return; } /* A function that gets executed when we want to change the state of the fallback. */ static gboolean fallback_timer_expire (gpointer data) { g_return_val_if_fail(IS_APP_INDICATOR(data), FALSE); AppIndicatorPrivate * priv = APP_INDICATOR(data)->priv; AppIndicatorClass * class = APP_INDICATOR_GET_CLASS(data); if (priv->status_icon == NULL) { if (class->fallback != NULL) { priv->status_icon = class->fallback(APP_INDICATOR(data)); } } else { if (class->unfallback != NULL) { class->unfallback(APP_INDICATOR(data), priv->status_icon); priv->status_icon = NULL; } else { g_warning("No 'unfallback' function but the 'fallback' function returned a non-NULL result."); } } priv->fallback_timer = 0; return FALSE; } /* emit a NEW_ICON signal in response for the theme change */ static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data) { g_signal_emit (user_data, signals[NEW_ICON], 0); AppIndicator * self = (AppIndicator *)user_data; AppIndicatorPrivate *priv = self->priv; if (priv->dbus_registration != 0 && priv->connection != NULL) { GError * error = NULL; g_dbus_connection_emit_signal(priv->connection, NULL, priv->path, NOTIFICATION_ITEM_DBUS_IFACE, "NewIcon", NULL, &error); if (error != NULL) { g_warning("Unable to send signal for NewIcon: %s", error->message); g_error_free(error); } } return; } /* Creates a StatusIcon that can be used when the application indicator area isn't available. */ static GtkStatusIcon * fallback (AppIndicator * self) { GtkStatusIcon * icon = gtk_status_icon_new(); gtk_status_icon_set_name(icon, app_indicator_get_id(self)); const gchar * title = app_indicator_get_title(self); if (title != NULL) { gtk_status_icon_set_title(icon, title); } g_signal_connect(G_OBJECT(self), APP_INDICATOR_SIGNAL_NEW_STATUS, G_CALLBACK(status_icon_status_wrapper), icon); g_signal_connect(G_OBJECT(self), APP_INDICATOR_SIGNAL_NEW_ICON, G_CALLBACK(status_icon_changes), icon); g_signal_connect(G_OBJECT(self), APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON, G_CALLBACK(status_icon_changes), icon); status_icon_changes(self, icon); g_signal_connect(G_OBJECT(icon), "activate", G_CALLBACK(status_icon_activate), self); g_signal_connect(G_OBJECT(icon), "popup-menu", G_CALLBACK(status_icon_menu_activate), self); g_signal_connect(G_OBJECT(icon), "scroll-event", G_CALLBACK(scroll_event_wrapper), self); g_signal_connect(G_OBJECT(icon), "button-release-event", G_CALLBACK(middle_click_wrapper), self); return icon; } /* A wrapper as the status update prototype is a little bit different, but we want to handle it the same. */ static void status_icon_status_wrapper (AppIndicator * self, const gchar * status, gpointer data) { return status_icon_changes(self, data); } /* A wrapper for redirecting the scroll events to the app-indicator from status icon widget. */ static gboolean scroll_event_wrapper (GtkWidget *status_icon, GdkEventScroll *event, gpointer data) { g_return_val_if_fail(IS_APP_INDICATOR(data), FALSE); AppIndicator * app = APP_INDICATOR(data); g_signal_emit(app, signals[SCROLL_EVENT], 0, 1, event->direction); return TRUE; } static gboolean middle_click_wrapper (GtkWidget *status_icon, GdkEventButton *event, gpointer data) { g_return_val_if_fail(IS_APP_INDICATOR(data), FALSE); AppIndicator * app = APP_INDICATOR(data); AppIndicatorPrivate *priv = app->priv; if (event->button == 2 && event->type == GDK_BUTTON_RELEASE) { GtkAllocation alloc; gint px = event->x; gint py = event->y; gtk_widget_get_allocation (status_icon, &alloc); GtkWidget *menuitem = priv->sec_activate_target; if (px >= 0 && px < alloc.width && py >= 0 && py < alloc.height && priv->sec_activate_enabled && menuitem && gtk_widget_get_visible (menuitem) && gtk_widget_get_sensitive (menuitem)) { gtk_widget_activate (menuitem); return TRUE; } } return FALSE; } /* This tracks changes to either the status or the icons that are associated with the app indicator */ static void status_icon_changes (AppIndicator * self, gpointer data) { GtkStatusIcon * icon = GTK_STATUS_ICON(data); /* add the icon_theme_path once if needed */ GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); const gchar *theme_path = self->priv->absolute_icon_theme_path ? self->priv->absolute_icon_theme_path : self->priv->icon_theme_path; if (theme_path != NULL) { gchar **path; gint n_elements, i; gboolean found=FALSE; gtk_icon_theme_get_search_path(icon_theme, &path, &n_elements); for (i=0; i< n_elements; i++) { if(g_strcmp0(path[i], theme_path) == 0) { found=TRUE; break; } } if(!found) { gtk_icon_theme_append_search_path(icon_theme, theme_path); } g_strfreev (path); } const gchar * icon_name = NULL; switch (app_indicator_get_status(self)) { case APP_INDICATOR_STATUS_PASSIVE: /* hide first to avoid that the change is visible to the user */ gtk_status_icon_set_visible(icon, FALSE); icon_name = app_indicator_get_icon(self); break; case APP_INDICATOR_STATUS_ACTIVE: icon_name = app_indicator_get_icon(self); gtk_status_icon_set_visible(icon, TRUE); break; case APP_INDICATOR_STATUS_ATTENTION: /* get the _attention_ icon here */ icon_name = app_indicator_get_attention_icon(self); gtk_status_icon_set_visible(icon, TRUE); break; }; if (icon_name != NULL) { gchar *snapped_icon = append_snap_prefix(icon_name); if (g_file_test(icon_name, G_FILE_TEST_EXISTS)) { gtk_status_icon_set_from_file(icon, icon_name); } else if (snapped_icon && g_file_test(snapped_icon, G_FILE_TEST_EXISTS)) { gtk_status_icon_set_from_file(icon, snapped_icon); } else { gchar *longname = append_panel_icon_suffix(icon_name); if (longname != NULL && gtk_icon_theme_has_icon (icon_theme, longname)) { gtk_status_icon_set_from_icon_name(icon, longname); } else { gtk_status_icon_set_from_icon_name(icon, icon_name); } g_free(longname); } g_free(snapped_icon); } return; } /* Handles the activate action by the status icon by showing the menu in a popup. */ static void status_icon_activate (GtkStatusIcon * icon, gpointer data) { GtkMenu * menu = app_indicator_get_menu(APP_INDICATOR(data)); if (menu == NULL) return; gtk_menu_popup(menu, NULL, /* Parent Menu */ NULL, /* Parent item */ gtk_status_icon_position_menu, icon, 1, /* Button */ gtk_get_current_event_time()); return; } /* Handles the right-click action by the status icon by showing the menu in a popup. */ static void status_icon_menu_activate (GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data) { status_icon_activate(status_icon, user_data); } /* Removes the status icon as the application indicator area is now up and running again. */ static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon) { g_signal_handlers_disconnect_by_func(G_OBJECT(self), status_icon_status_wrapper, status_icon); g_signal_handlers_disconnect_by_func(G_OBJECT(self), status_icon_changes, status_icon); g_signal_handlers_disconnect_by_func(G_OBJECT(self), scroll_event_wrapper, status_icon); g_signal_handlers_disconnect_by_func(G_OBJECT(self), middle_click_wrapper, status_icon); gtk_status_icon_set_visible(status_icon, FALSE); g_object_unref(G_OBJECT(status_icon)); return; } /* A helper function that appends PANEL_ICON_SUFFIX to the given icon name if it's missing. */ static gchar * append_panel_icon_suffix (const gchar *icon_name) { gchar * long_name = NULL; if (!g_str_has_suffix (icon_name, PANEL_ICON_SUFFIX)) { long_name = g_strdup_printf("%s-%s", icon_name, PANEL_ICON_SUFFIX); } else { long_name = g_strdup (icon_name); } return long_name; } static gboolean widget_is_menu_child(AppIndicator * self, GtkWidget *child) { g_return_val_if_fail(IS_APP_INDICATOR(self), FALSE); if (!self->priv->menu) return FALSE; if (!child) return FALSE; GtkWidget *parent; while ((parent = gtk_widget_get_parent(child))) { if (parent == self->priv->menu) return TRUE; if (GTK_IS_MENU(parent)) child = gtk_menu_get_attach_widget(GTK_MENU(parent)); else child = parent; } return FALSE; } static void sec_activate_target_parent_changed(GtkWidget *menuitem, GtkWidget *old_parent, gpointer data) { g_return_if_fail(IS_APP_INDICATOR(data)); AppIndicator *self = data; self->priv->sec_activate_enabled = widget_is_menu_child(self, menuitem); } /* ************************* */ /* Public Functions */ /* ************************* */ /** * app_indicator_new: * @id: The unique id of the indicator to create. * @icon_name: The icon name for this indicator * @category: The category of indicator. * * Creates a new #AppIndicator setting the properties: * #AppIndicator:id with @id, #AppIndicator:category with @category * and #AppIndicator:icon-name with @icon_name. * * Return value: A pointer to a new #AppIndicator object. */ AppIndicator * app_indicator_new (const gchar *id, const gchar *icon_name, AppIndicatorCategory category) { AppIndicator *indicator = g_object_new (APP_INDICATOR_TYPE, PROP_ID_S, id, PROP_CATEGORY_S, category_from_enum (category), PROP_ICON_NAME_S, icon_name, NULL); return indicator; } /** * app_indicator_new_with_path: * @id: The unique id of the indicator to create. * @icon_name: The icon name for this indicator * @category: The category of indicator. * @icon_theme_path: A custom path for finding icons. * Creates a new #AppIndicator setting the properties: * #AppIndicator:id with @id, #AppIndicator:category with @category, * #AppIndicator:icon-name with @icon_name and #AppIndicator:icon-theme-path * with @icon_theme_path. * * Return value: A pointer to a new #AppIndicator object. */ AppIndicator * app_indicator_new_with_path (const gchar *id, const gchar *icon_name, AppIndicatorCategory category, const gchar *icon_theme_path) { AppIndicator *indicator = g_object_new (APP_INDICATOR_TYPE, PROP_ID_S, id, PROP_CATEGORY_S, category_from_enum (category), PROP_ICON_NAME_S, icon_name, PROP_ICON_THEME_PATH_S, icon_theme_path, NULL); return indicator; } /** * app_indicator_get_type: * * Generates or returns the unique #GType for #AppIndicator. * * Return value: A unique #GType for #AppIndicator objects. */ /** * app_indicator_set_status: * @self: The #AppIndicator object to use * @status: The status to set for this indicator * * Wrapper function for property #AppIndicator:status. */ void app_indicator_set_status (AppIndicator *self, AppIndicatorStatus status) { g_return_if_fail (IS_APP_INDICATOR (self)); if (self->priv->status != status) { GEnumValue *value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), status); self->priv->status = status; g_signal_emit (self, signals[NEW_STATUS], 0, value->value_nick); if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) { GError * error = NULL; g_dbus_connection_emit_signal(self->priv->connection, NULL, self->priv->path, NOTIFICATION_ITEM_DBUS_IFACE, "NewStatus", g_variant_new("(s)", value->value_nick), &error); if (error != NULL) { g_warning("Unable to send signal for NewStatus: %s", error->message); g_error_free(error); } } } return; } /** * app_indicator_set_attention_icon: * @self: The #AppIndicator object to use * @icon_name: The name of the attention icon to set for this indicator * * Wrapper for app_indicator_set_attention_icon_full() with a NULL * description. * * Deprecated: Use app_indicator_set_attention_icon_full() instead. */ void app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) { return app_indicator_set_attention_icon_full(self, icon_name, NULL); } /** * app_indicator_set_attention_icon_full: * @self: The #AppIndicator object to use * @icon_name: The name of the attention icon to set for this indicator * @icon_desc: A textual description of the icon * * Wrapper function for property #AppIndicator:attention-icon-name. */ void app_indicator_set_attention_icon_full (AppIndicator *self, const gchar *icon_name, const gchar * icon_desc) { g_return_if_fail (IS_APP_INDICATOR (self)); g_return_if_fail (icon_name != NULL); gboolean changed = FALSE; if (g_strcmp0 (self->priv->attention_icon_name, icon_name) != 0) { g_free (self->priv->attention_icon_name); self->priv->attention_icon_name = g_strdup (icon_name); g_free(self->priv->absolute_attention_icon_name); self->priv->absolute_attention_icon_name = NULL; if (icon_name && icon_name[0] == '/') { self->priv->absolute_attention_icon_name = append_snap_prefix (icon_name); } changed = TRUE; } if (g_strcmp0(self->priv->att_accessible_desc, icon_desc) != 0) { g_free (self->priv->att_accessible_desc); self->priv->att_accessible_desc = g_strdup (icon_desc); changed = TRUE; } if (changed) { g_signal_emit (self, signals[NEW_ATTENTION_ICON], 0); if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) { GError * error = NULL; g_dbus_connection_emit_signal(self->priv->connection, NULL, self->priv->path, NOTIFICATION_ITEM_DBUS_IFACE, "NewAttentionIcon", NULL, &error); if (error != NULL) { g_warning("Unable to send signal for NewAttentionIcon: %s", error->message); g_error_free(error); } } } return; } /** * app_indicator_set_icon: * @self: The #AppIndicator object to use * @icon_name: The icon name to set. * * Wrapper function for app_indicator_set_icon_full() with a NULL * description. * * Deprecated: Use app_indicator_set_icon_full() */ void app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) { return app_indicator_set_icon_full(self, icon_name, NULL); } /** * app_indicator_set_icon_full: * @self: The #AppIndicator object to use * @icon_name: The icon name to set. * @icon_desc: A textual description of the icon for accessibility * * Sets the default icon to use when the status is active but * not set to attention. In most cases, this should be the * application icon for the program. * * Wrapper function for property #AppIndicator:icon-name and * #AppIndicator::icon-desc. */ void app_indicator_set_icon_full (AppIndicator *self, const gchar *icon_name, const gchar * icon_desc) { g_return_if_fail (IS_APP_INDICATOR (self)); g_return_if_fail (icon_name != NULL); gboolean changed = FALSE; if (g_strcmp0 (self->priv->icon_name, icon_name) != 0) { if (self->priv->icon_name) { g_free (self->priv->icon_name); } self->priv->icon_name = g_strdup(icon_name); g_free(self->priv->absolute_icon_name); self->priv->absolute_icon_name = NULL; if (icon_name && icon_name[0] == '/') { self->priv->absolute_icon_name = append_snap_prefix (icon_name); } changed = TRUE; } if (g_strcmp0(self->priv->accessible_desc, icon_desc) != 0) { if (self->priv->accessible_desc != NULL) { g_free(self->priv->accessible_desc); } self->priv->accessible_desc = g_strdup(icon_desc); changed = TRUE; } if (changed) { g_signal_emit (self, signals[NEW_ICON], 0); if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) { GError * error = NULL; g_dbus_connection_emit_signal(self->priv->connection, NULL, self->priv->path, NOTIFICATION_ITEM_DBUS_IFACE, "NewIcon", NULL, &error); if (error != NULL) { g_warning("Unable to send signal for NewIcon: %s", error->message); g_error_free(error); } } } return; } /** * app_indicator_set_label: * @self: The #AppIndicator object to use * @label: The label to show next to the icon. * @guide: A guide to size the label correctly. * * This is a wrapper function for the #AppIndicator:label and * #AppIndicator:guide properties. This function can take #NULL * as either @label or @guide and will clear the entries. */ void app_indicator_set_label (AppIndicator *self, const gchar * label, const gchar * guide) { g_return_if_fail (IS_APP_INDICATOR (self)); /* Note: The label can be NULL, it's okay */ /* Note: The guide can be NULL, it's okay */ g_object_set(G_OBJECT(self), PROP_LABEL_S, label == NULL ? "" : label, PROP_LABEL_GUIDE_S, guide == NULL ? "" : guide, NULL); return; } static const gchar * get_snap_prefix () { const gchar *snap = g_getenv ("SNAP"); return (snap && *snap != '\0') ? snap : NULL; } static gchar * append_snap_prefix (const gchar *path) { gint i; gchar real_path[PATH_MAX]; const gchar *snap = get_snap_prefix (); if (snap != NULL && path != NULL) { if (realpath (path, real_path) != NULL) { path = real_path; } if (g_str_has_prefix (path, "/tmp/")) { g_warning ("Using '/tmp' paths in SNAP environment will lead to unreadable resources"); return NULL; } if (g_str_has_prefix (path, snap) || g_str_has_prefix (path, g_get_home_dir ()) || g_str_has_prefix (path, g_get_user_cache_dir ()) || g_str_has_prefix (path, g_get_user_config_dir ()) || g_str_has_prefix (path, g_get_user_data_dir ()) || g_str_has_prefix (path, g_get_user_runtime_dir ())) { return g_strdup (path); } for (i = 0; i < G_USER_N_DIRECTORIES; ++ i) { if (g_str_has_prefix (path, g_get_user_special_dir (i))) { return g_strdup (path); } } return g_build_path (G_DIR_SEPARATOR_S, snap, path, NULL); } return NULL; } static gchar * get_real_theme_path (AppIndicator * self) { const gchar *theme_path = self->priv->icon_theme_path; gchar *snapped_path = append_snap_prefix (theme_path); if (snapped_path != NULL) { return snapped_path; } else if (get_snap_prefix ()) { return g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (), "icons", NULL); } return NULL; } /** * app_indicator_set_icon_theme_path: * @self: The #AppIndicator object to use * @icon_theme_path: The icon theme path to set. * * Sets the path to use when searching for icons. */ void app_indicator_set_icon_theme_path (AppIndicator *self, const gchar *icon_theme_path) { g_return_if_fail (IS_APP_INDICATOR (self)); if (g_strcmp0 (self->priv->icon_theme_path, icon_theme_path) != 0) { if (self->priv->icon_theme_path != NULL) g_free(self->priv->icon_theme_path); self->priv->icon_theme_path = g_strdup(icon_theme_path); g_free (self->priv->absolute_icon_theme_path); self->priv->absolute_icon_theme_path = get_real_theme_path (self); g_signal_emit (self, signals[NEW_ICON_THEME_PATH], 0, self->priv->icon_theme_path); if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) { const gchar *theme_path = self->priv->absolute_icon_theme_path ? self->priv->absolute_icon_theme_path : self->priv->icon_theme_path; GError * error = NULL; g_dbus_connection_emit_signal(self->priv->connection, NULL, self->priv->path, NOTIFICATION_ITEM_DBUS_IFACE, "NewIconThemePath", g_variant_new("(s)", theme_path ? theme_path : ""), &error); if (error != NULL) { g_warning("Unable to send signal for NewIconThemePath: %s", error->message); g_error_free(error); } } } return; } /* Does the dbusmenu related work. If there isn't a server, it builds one and if there are menus it runs the parse to put those menus into the server. */ static void setup_dbusmenu (AppIndicator *self) { AppIndicatorPrivate *priv; DbusmenuMenuitem *root = NULL; priv = self->priv; if (priv->menu) { root = dbusmenu_gtk_parse_menu_structure(priv->menu); } if (priv->menuservice == NULL) { gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s/Menu", priv->clean_id); priv->menuservice = dbusmenu_server_new (path); g_free(path); } dbusmenu_server_set_root (priv->menuservice, root); /* Drop our local ref as set_root should get it's own. */ if (root != NULL) { g_object_unref(root); } return; } /** * app_indicator_set_menu: * @self: The #AppIndicator * @menu: (allow-none): A #GtkMenu to set * * Sets the menu that should be shown when the Application Indicator * is clicked on in the panel. An application indicator will not * be rendered unless it has a menu. * * Wrapper function for property #AppIndicator:menu. */ void app_indicator_set_menu (AppIndicator *self, GtkMenu *menu) { AppIndicatorPrivate *priv; g_return_if_fail (IS_APP_INDICATOR (self)); g_return_if_fail (GTK_IS_MENU (menu)); g_return_if_fail (self->priv->clean_id != NULL); priv = self->priv; if (priv->menu != NULL) { g_object_unref (priv->menu); } priv->menu = GTK_WIDGET (menu); g_object_ref_sink (priv->menu); setup_dbusmenu (self); priv->sec_activate_enabled = widget_is_menu_child (self, priv->sec_activate_target); check_connect (self); return; } /** * app_indicator_set_ordering_index: * @self: The #AppIndicator * @ordering_index: A value for the ordering of this app indicator * * Sets the ordering index for the app indicator which effects the * placement of it on the panel. For almost all app indicator * this is not the function you're looking for. * * Wrapper function for property #AppIndicator:ordering-index. */ void app_indicator_set_ordering_index (AppIndicator *self, guint32 ordering_index) { g_return_if_fail (IS_APP_INDICATOR (self)); self->priv->ordering_index = ordering_index; return; } /** * app_indicator_set_secondary_activate_target: * @self: The #AppIndicator * @menuitem: (allow-none): A #GtkWidget to be activated on secondary activation * * Set the @menuitem to be activated when a secondary activation event (i.e. a * middle-click) is emitted over the #AppIndicator icon/label. * * The @menuitem can be also a complex #GtkWidget, but to get activated when * a secondary activation occurs in the #Appindicator, it must be a visible and * active child (or inner-child) of the #AppIndicator:menu. * * Setting @menuitem to %NULL causes to disable this feature. */ void app_indicator_set_secondary_activate_target (AppIndicator *self, GtkWidget *menuitem) { g_return_if_fail (IS_APP_INDICATOR (self)); AppIndicatorPrivate *priv = self->priv; if (priv->sec_activate_target) { g_signal_handlers_disconnect_by_func (priv->sec_activate_target, sec_activate_target_parent_changed, self); g_object_unref(G_OBJECT(priv->sec_activate_target)); priv->sec_activate_target = NULL; } if (menuitem == NULL) { return; } g_return_if_fail (GTK_IS_WIDGET (menuitem)); priv->sec_activate_target = g_object_ref(menuitem); priv->sec_activate_enabled = widget_is_menu_child(self, menuitem); g_signal_connect(menuitem, "parent-set", G_CALLBACK(sec_activate_target_parent_changed), self); } /** * app_indicator_set_title: * @self: The #AppIndicator * @title: (allow-none): Title of the app indicator * * Sets the title of the application indicator, or how it should be referred * in a human readable form. This string should be UTF-8 and localized as it * expected that users will set it. * * In the Unity desktop the most prominent place that this is show will be * in the HUD. HUD listings for this application indicator will start with * the title as the first part of the line for the menu items. * * Setting @title to %NULL removes the title. * * Since: 0.5 * */ void app_indicator_set_title (AppIndicator *self, const gchar * title) { g_return_if_fail (IS_APP_INDICATOR (self)); g_object_set(G_OBJECT(self), PROP_TITLE_S, title == NULL ? "": title, NULL); return; } /** * app_indicator_get_id: * @self: The #AppIndicator object to use * * Wrapper function for property #AppIndicator:id. * * Return value: The current ID */ const gchar * app_indicator_get_id (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); return self->priv->id; } /** * app_indicator_get_category: * @self: The #AppIndicator object to use * * Wrapper function for property #AppIndicator:category. * * Return value: The current category. */ AppIndicatorCategory app_indicator_get_category (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), APP_INDICATOR_CATEGORY_APPLICATION_STATUS); return self->priv->category; } /** * app_indicator_get_status: * @self: The #AppIndicator object to use * * Wrapper function for property #AppIndicator:status. * * Return value: The current status. */ AppIndicatorStatus app_indicator_get_status (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), APP_INDICATOR_STATUS_PASSIVE); return self->priv->status; } /** * app_indicator_get_icon: * @self: The #AppIndicator object to use * * Wrapper function for property #AppIndicator:icon-name. * * Return value: The current icon name. */ const gchar * app_indicator_get_icon (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); return self->priv->icon_name; } /** * app_indicator_get_icon_desc: * @self: The #AppIndicator object to use * * Wrapper function for property #AppIndicator:icon-desc. * * Return value: The current icon description. */ const gchar * app_indicator_get_icon_desc (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); return self->priv->accessible_desc; } /** * app_indicator_get_icon_theme_path: * @self: The #AppIndicator object to use * * Wrapper function for property #AppIndicator:icon-theme-path. * * Return value: The current icon theme path. */ const gchar * app_indicator_get_icon_theme_path (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); return self->priv->icon_theme_path; } /** * app_indicator_get_attention_icon: * @self: The #AppIndicator object to use * * Wrapper function for property #AppIndicator:attention-icon-name. * * Return value: The current attention icon name. */ const gchar * app_indicator_get_attention_icon (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); return self->priv->attention_icon_name; } /** * app_indicator_get_attention_icon_desc: * @self: The #AppIndicator object to use * * Wrapper function for property #AppIndicator:attention-icon-desc. * * Return value: The current attention icon description. */ const gchar * app_indicator_get_attention_icon_desc (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); return self->priv->att_accessible_desc; } /** * app_indicator_get_title: * @self: The #AppIndicator object to use * * Gets the title of the application indicator. See the function * app_indicator_set_title() for information on the title. * * Return value: The current title. * * Since: 0.5 * */ const gchar * app_indicator_get_title (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); return self->priv->title; } /** * app_indicator_get_menu: * @self: The #AppIndicator object to use * * Gets the menu being used for this application indicator. * Wrapper function for property #AppIndicator:menu. * * Returns: (transfer none): A #GtkMenu object or %NULL if one hasn't been set. */ GtkMenu * app_indicator_get_menu (AppIndicator *self) { AppIndicatorPrivate *priv; g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); priv = self->priv; return GTK_MENU(priv->menu); } /** * app_indicator_get_label: * @self: The #AppIndicator object to use * * Wrapper function for property #AppIndicator:label. * * Return value: The current label. */ const gchar * app_indicator_get_label (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); return self->priv->label; } /** * app_indicator_get_label_guide: * @self: The #AppIndicator object to use * * Wrapper function for property #AppIndicator:label-guide. * * Return value: The current label guide. */ const gchar * app_indicator_get_label_guide (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); return self->priv->label_guide; } /** * app_indicator_get_ordering_index: * @self: The #AppIndicator object to use * * Wrapper function for property #AppIndicator:ordering-index. * * Return value: The current ordering index. */ guint32 app_indicator_get_ordering_index (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), 0); if (self->priv->ordering_index == 0) { return _generate_id(self->priv->category, self->priv->id); } else { return self->priv->ordering_index; } } /** * app_indicator_get_secondary_activate_target: * @self: The #AppIndicator object to use * * Gets the menuitem being called on secondary-activate event. * * Returns: (transfer none): A #GtkWidget object or %NULL if none has been set. */ GtkWidget * app_indicator_get_secondary_activate_target (AppIndicator *self) { g_return_val_if_fail (IS_APP_INDICATOR (self), NULL); return GTK_WIDGET(self->priv->sec_activate_target); } #define APP_INDICATOR_SHORTY_NICK "app-indicator-shorty-nick" /* Callback when an item from the desktop shortcuts gets called. */ static void shorty_activated_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) { gchar * nick = g_object_get_data(G_OBJECT(mi), APP_INDICATOR_SHORTY_NICK); g_return_if_fail(nick != NULL); g_return_if_fail(IS_APP_INDICATOR(user_data)); AppIndicator * self = APP_INDICATOR(user_data); AppIndicatorPrivate *priv = self->priv; g_return_if_fail(priv->shorties != NULL); indicator_desktop_shortcuts_nick_exec_with_context(priv->shorties, nick, NULL); return; } /** * app_indicator_build_menu_from_desktop: * @self: The #AppIndicator object to use * @desktop_file: A path to the desktop file to build the menu from * @desktop_profile: Which entries should be used from the desktop file * * This function allows for building the Application Indicator menu * from a static desktop file. */ void app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file, const gchar * desktop_profile) { g_return_if_fail(IS_APP_INDICATOR(self)); AppIndicatorPrivate *priv = self->priv; /* Build a new shortcuts object */ if (priv->shorties != NULL) { g_object_unref(priv->shorties); priv->shorties = NULL; } priv->shorties = indicator_desktop_shortcuts_new(desktop_file, desktop_profile); g_return_if_fail(priv->shorties != NULL); const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(priv->shorties); int nick_num; /* Place the items on a dbusmenu */ DbusmenuMenuitem * root = dbusmenu_menuitem_new(); for (nick_num = 0; nicks[nick_num] != NULL; nick_num++) { DbusmenuMenuitem * item = dbusmenu_menuitem_new(); g_object_set_data(G_OBJECT(item), APP_INDICATOR_SHORTY_NICK, (gpointer)nicks[nick_num]); gchar * name = indicator_desktop_shortcuts_nick_get_name(priv->shorties, nicks[nick_num]); dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, name); g_free(name); g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(shorty_activated_cb), self); dbusmenu_menuitem_child_append(root, item); } /* Swap it if needed */ if (priv->menuservice == NULL) { gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s/Menu", priv->clean_id); priv->menuservice = dbusmenu_server_new (path); g_free(path); } dbusmenu_server_set_root (priv->menuservice, root); if (priv->menu != NULL) { g_object_unref(G_OBJECT(priv->menu)); priv->menu = NULL; } return; } ./autogen.sh0000755000004100000410000000034513700622663013253 0ustar www-datawww-data#!/bin/sh PKG_NAME="libappindicator" which gnome-autogen.sh || { echo "You need gnome-common from GNOME SVN" exit 1 } gtkdocize || exit 1 USE_GNOME2_MACROS=1 \ USE_COMMON_DOC_BUILD=yes \ gnome-autogen.sh --enable-gtk-doc $@ ./ChangeLog0000644000004100000410000000000013700622663013010 0ustar www-datawww-data./Makefile.am.enum0000644000004100000410000000243713700622663014255 0ustar www-datawww-data# Rules for generating enumeration types using glib-mkenums # # Define: # glib_enum_h = header template file # glib_enum_c = source template file # glib_enum_headers = list of headers to parse # # before including Makefile.am.enums. You will also need to have # the following targets already defined: # # CLEANFILES # DISTCLEANFILES # BUILT_SOURCES # EXTRA_DIST # # Author: Emmanuele Bassi enum_tmpl_h=$(glib_enum_h:.h=.h.in) enum_tmpl_c=$(glib_enum_c:.c=.c.in) CLEANFILES += stamp-enum-types DISTCLEANFILES += $(glib_enum_h) $(glib_enum_c) BUILT_SOURCES += $(glib_enum_h) $(glib_enum_c) EXTRA_DIST += $(enum_tmpl_h) $(enum_tmpl_c) stamp-enum-types: $(glib_enum_headers) $(QUIET_GEN)mkdir -p `dirname $(builddir)/$(glib_enum_h)` $(QUIET_GEN)$(GLIB_MKENUMS) \ --template $(srcdir)/$(enum_tmpl_h) \ $(glib_enum_headers) > xgen-eh \ && (cmp -s xgen-eh $(builddir)/$(glib_enum_h) || cp -f xgen-eh $(builddir)/$(glib_enum_h)) \ && rm -f xgen-eh \ && echo timestamp > $(@F) $(glib_enum_h): stamp-enum-types @true $(glib_enum_c): $(glib_enum_h) $(QUIET_GEN)mkdir -p `dirname $(builddir)/$(glib_enum_c)` $(QUIET_GEN)$(GLIB_MKENUMS) \ --template $(srcdir)/$(enum_tmpl_c) \ $(glib_enum_headers) > xgen-ec \ && cp -f xgen-ec $(builddir)/$(glib_enum_c) \ && rm -f xgen-ec ./Makefile.am.coverage0000644000004100000410000000250513700622663015100 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 if HAVE_GCOV 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 coverage-html: clean-gcda -$(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: clean-gcda -$(MAKE) $(AM_MAKEFLAGS) -k check $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr generate-coverage-gcovr: @echo Generating coverage GCOVR report $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml clean-coverage-gcovr: clean-gcda -rm -rf $(top_builddir)/coverage.xml endif # HAVE_GCOVR endif # HAVE_GCOV ./tests/0000755000004100000410000000000013700622676012416 5ustar www-datawww-data./tests/test-libappindicator-dbus-server.c0000644000004100000410000000312513700622663021137 0ustar www-datawww-data/* Tests for the libappindicator library that are over DBus. This is the server side of those tests. Copyright 2009 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #include #include #include "test-defines.h" static GMainLoop * mainloop = NULL; gboolean kill_func (gpointer userdata) { g_main_loop_quit(mainloop); return FALSE; } gint main (gint argc, gchar * argv[]) { gtk_init(&argc, &argv); AppIndicator * ci = app_indicator_new (TEST_ID, TEST_ICON_NAME, TEST_CATEGORY); app_indicator_set_status (ci, TEST_STATE); app_indicator_set_attention_icon (ci, TEST_ATTENTION_ICON_NAME); GtkMenu * menu = GTK_MENU(gtk_menu_new()); GtkMenuItem * item = GTK_MENU_ITEM(gtk_menu_item_new_with_label("Label")); gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(item)); app_indicator_set_menu(ci, menu); g_timeout_add_seconds(2, kill_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); g_object_unref(G_OBJECT(ci)); g_debug("Quiting"); return 0; } ./tests/test-libappindicator-fallback-watcher.c0000644000004100000410000001350513700622676022077 0ustar www-datawww-data/* This puts the NotificationWatcher on the bus, kinda. Enough to trick the Item into unfalling back. Copyright 2010 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #include #include "../src/dbus-shared.h" typedef struct { int status; GMainLoop *loop; } TestData; static const gchar introspection_xml[] = "" " " " " " " " " " " " " ""; static gboolean kill_func (gpointer user_data) { TestData *data; data = user_data; data->status = EXIT_FAILURE; g_main_loop_quit (data->loop); return G_SOURCE_REMOVE; } static void handle_method_call (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { TestData *data; data = user_data; if (g_strcmp0 (method_name, "RegisterStatusNotifierItem") == 0) { g_dbus_method_invocation_return_value (invocation, NULL); g_main_loop_quit (data->loop); } } static GVariant * handle_get_property (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *property_name, GError **error, gpointer user_data) { if (g_strcmp0 (property_name, "IsStatusNotifierHostRegistered") == 0) return g_variant_new_boolean (TRUE); return NULL; } static const GDBusInterfaceVTable interface_vtable = { handle_method_call, handle_get_property, NULL }; static void bus_acquired_cb (GDBusConnection *connection, const gchar *name, gpointer user_data) { GDBusNodeInfo *introspection_info; introspection_info = g_dbus_node_info_new_for_xml (introspection_xml, NULL); g_dbus_connection_register_object (connection, NOTIFICATION_WATCHER_DBUS_OBJ, introspection_info->interfaces[0], &interface_vtable, user_data, NULL, NULL); g_dbus_node_info_unref (introspection_info); } static void name_lost_cb (GDBusConnection *connection, const gchar *name, gpointer user_data) { TestData *data; data = user_data; data->status = EXIT_FAILURE; g_main_loop_quit (data->loop); } int main (int argc, char *argv[]) { GDBusProxy *proxy; gboolean has_owner; gint owner_count; TestData data; guint owner_id; g_debug ("Waiting to init."); proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", NULL, NULL); has_owner = FALSE; owner_count = 0; while (!has_owner && owner_count < 10000) { GVariant *variant; variant = g_dbus_proxy_call_sync (proxy, "NameHasOwner", g_variant_new ("(s)", "org.test"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); if (variant != NULL) { g_variant_get (variant, "(b)", &has_owner); g_variant_unref (variant); } g_usleep (500000); owner_count++; } g_object_unref (proxy); if (owner_count == 10000) { g_error ("Unable to get name owner after 10000 tries"); return EXIT_FAILURE; } g_usleep (500000); g_debug ("Initing"); data.status = EXIT_SUCCESS; data.loop = g_main_loop_new (NULL, FALSE); owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, NOTIFICATION_WATCHER_DBUS_ADDR, G_BUS_NAME_OWNER_FLAGS_NONE, bus_acquired_cb, NULL, name_lost_cb, &data, NULL); /* This is the final kill function. It really shouldn't happen * unless we get an error. */ g_timeout_add_seconds (20, kill_func, &data); g_debug ("Entering Mainloop"); g_main_loop_run (data.loop); g_main_loop_unref (data.loop); g_bus_unown_name (owner_id); g_debug ("Exiting"); return data.status; } ./tests/run-xvfb.sh0000644000004100000410000000156513700622663014524 0ustar www-datawww-dataif [ "$DISPLAY" == "" ]; then Xvfb -ac -noreset -screen 0 800x600x16 -help 2>/dev/null 1>&2 XID=`for id in 101 102 103 104 105 106 107 197 199 211 223 227 293 307 308 309 310 311 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 4703 4721 4723 4729 4733 4751 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 ; do test -e /tmp/.X$id-lock || { echo $id; exit 0; }; done; exit 1` { Xvfb -ac -noreset -screen 0 800x600x16 :$XID -screen 0 800x600x16 -nolisten tcp -auth /dev/null >/dev/null 2>&1 & trap "kill -15 $! " 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 sleep 2 fi ./tests/test-defines.h0000644000004100000410000000222213700622663015153 0ustar www-datawww-data/* Testing defines to be shared between various tests. Copyright 2009 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #define TEST_ID "my-id" #define TEST_ICON_NAME "my-icon-name" #define TEST_ATTENTION_ICON_NAME "my-attention-icon-name" #define TEST_STATE APP_INDICATOR_STATUS_ACTIVE #define TEST_STATE_S "Active" #define TEST_CATEGORY APP_INDICATOR_CATEGORY_APPLICATION_STATUS #define TEST_CATEGORY_S "ApplicationStatus" #define TEST_OBJECT "/an/object/path/to/use" ./tests/test-libappindicator.desktop0000644000004100000410000000064513700622663020133 0ustar www-datawww-data[Desktop Entry] Name=AppIndicator Test GenericName=Test Comment=This is only a test Exec=/usr/bin/false Terminal=false Type=Application Actions=Short1;Short2;Short3; [Desktop Action Short1] Name=Shortcut 1 Exec=/usr/bin/true OnlyShowIn=Test Program; [Desktop Action Short2] Name=Shortcut 2 Exec=/usr/bin/true OnlyShowIn=Test Program; [Desktop Action Short3] Name=Shortcut 3 Exec=/usr/bin/true OnlyShowIn=Test Program; ./tests/test-libappindicator.c0000644000004100000410000003510513700622663016703 0ustar www-datawww-data/* Tests for the libappindicator library. Copyright 2009 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #include #include #include #include #include static gboolean allow_warnings (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) { // By default, gtest will fail a test on even a warning message. // But since some of our sub-libraries are noisy (especially at-spi2), // only fail on critical or worse. return ((log_level & G_LOG_LEVEL_MASK) <= G_LOG_LEVEL_CRITICAL); } void test_libappindicator_prop_signals_status_helper (AppIndicator * ci, gchar * status, gboolean * signalactivated) { *signalactivated = TRUE; return; } void test_libappindicator_prop_signals_helper (AppIndicator * ci, gboolean * signalactivated) { *signalactivated = TRUE; return; } void test_libappindicator_prop_signals (void) { g_test_log_set_fatal_handler (allow_warnings, NULL); AppIndicator * ci = app_indicator_new ("test-app-indicator", "indicator-messages", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_assert(ci != NULL); gboolean signaled = FALSE; gulong handlerid; handlerid = 0; handlerid = g_signal_connect(G_OBJECT(ci), "new-icon", G_CALLBACK(test_libappindicator_prop_signals_helper), &signaled); g_assert(handlerid != 0); handlerid = 0; handlerid = g_signal_connect(G_OBJECT(ci), "new-attention-icon", G_CALLBACK(test_libappindicator_prop_signals_helper), &signaled); g_assert(handlerid != 0); handlerid = 0; handlerid = g_signal_connect(G_OBJECT(ci), "new-status", G_CALLBACK(test_libappindicator_prop_signals_status_helper), &signaled); g_assert(handlerid != 0); signaled = FALSE; app_indicator_set_icon(ci, "bob"); g_assert(signaled); signaled = FALSE; app_indicator_set_icon(ci, "bob"); g_assert(!signaled); signaled = FALSE; app_indicator_set_icon(ci, "al"); g_assert(signaled); signaled = FALSE; app_indicator_set_attention_icon(ci, "bob"); g_assert(signaled); signaled = FALSE; app_indicator_set_attention_icon(ci, "bob"); g_assert(!signaled); signaled = FALSE; app_indicator_set_attention_icon(ci, "al"); g_assert(signaled); signaled = FALSE; app_indicator_set_status(ci, APP_INDICATOR_STATUS_PASSIVE); g_assert(!signaled); signaled = FALSE; app_indicator_set_status(ci, APP_INDICATOR_STATUS_ACTIVE); g_assert(signaled); signaled = FALSE; app_indicator_set_status(ci, APP_INDICATOR_STATUS_ACTIVE); g_assert(!signaled); signaled = FALSE; app_indicator_set_status(ci, APP_INDICATOR_STATUS_ATTENTION); g_assert(signaled); return; } void test_libappindicator_init_set_props (void) { g_test_log_set_fatal_handler (allow_warnings, NULL); AppIndicator * ci = app_indicator_new ("my-id", "my-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_assert(ci != NULL); app_indicator_set_status(ci, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_attention_icon(ci, "my-attention-name"); app_indicator_set_title(ci, "My Title"); g_assert(!g_strcmp0("my-id", app_indicator_get_id(ci))); g_assert(!g_strcmp0("my-name", app_indicator_get_icon(ci))); g_assert(!g_strcmp0("my-attention-name", app_indicator_get_attention_icon(ci))); g_assert(!g_strcmp0("My Title", app_indicator_get_title(ci))); g_assert(app_indicator_get_status(ci) == APP_INDICATOR_STATUS_ACTIVE); g_assert(app_indicator_get_category(ci) == APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_object_unref(G_OBJECT(ci)); return; } void test_libappindicator_init_with_props (void) { g_test_log_set_fatal_handler (allow_warnings, NULL); AppIndicator * ci = app_indicator_new ("my-id", "my-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_status (ci, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_attention_icon (ci, "my-attention-name"); g_assert(ci != NULL); g_assert(!g_strcmp0("my-id", app_indicator_get_id(ci))); g_assert(!g_strcmp0("my-name", app_indicator_get_icon(ci))); g_assert(!g_strcmp0("my-attention-name", app_indicator_get_attention_icon(ci))); g_assert(app_indicator_get_status(ci) == APP_INDICATOR_STATUS_ACTIVE); g_assert(app_indicator_get_category(ci) == APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_object_unref(G_OBJECT(ci)); return; } void test_libappindicator_init (void) { g_test_log_set_fatal_handler (allow_warnings, NULL); AppIndicator * ci = app_indicator_new ("my-id", "my-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_assert(ci != NULL); g_object_unref(G_OBJECT(ci)); return; } void test_libappindicator_set_label (void) { g_test_log_set_fatal_handler (allow_warnings, NULL); AppIndicator * ci = app_indicator_new ("my-id", "my-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_assert(ci != NULL); g_assert(app_indicator_get_label(ci) == NULL); g_assert(app_indicator_get_label_guide(ci) == NULL); /* First check all the clearing modes, this is important as we're going to use them later, we need them to work. */ app_indicator_set_label(ci, NULL, NULL); g_assert(app_indicator_get_label(ci) == NULL); g_assert(app_indicator_get_label_guide(ci) == NULL); app_indicator_set_label(ci, "", NULL); g_assert(app_indicator_get_label(ci) == NULL); g_assert(app_indicator_get_label_guide(ci) == NULL); app_indicator_set_label(ci, NULL, ""); g_assert(app_indicator_get_label(ci) == NULL); g_assert(app_indicator_get_label_guide(ci) == NULL); app_indicator_set_label(ci, "", ""); g_assert(app_indicator_get_label(ci) == NULL); g_assert(app_indicator_get_label_guide(ci) == NULL); app_indicator_set_label(ci, "label", ""); g_assert(g_strcmp0(app_indicator_get_label(ci), "label") == 0); g_assert(app_indicator_get_label_guide(ci) == NULL); app_indicator_set_label(ci, NULL, NULL); g_assert(app_indicator_get_label(ci) == NULL); g_assert(app_indicator_get_label_guide(ci) == NULL); app_indicator_set_label(ci, "label", "guide"); g_assert(g_strcmp0(app_indicator_get_label(ci), "label") == 0); g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide") == 0); app_indicator_set_label(ci, "label2", "guide"); g_assert(g_strcmp0(app_indicator_get_label(ci), "label2") == 0); g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide") == 0); app_indicator_set_label(ci, "trick-label", "trick-guide"); g_assert(g_strcmp0(app_indicator_get_label(ci), "trick-label") == 0); g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "trick-guide") == 0); g_object_unref(G_OBJECT(ci)); return; } void test_libappindicator_set_menu (void) { g_test_log_set_fatal_handler (allow_warnings, NULL); AppIndicator * ci = app_indicator_new ("my-id", "my-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_assert(ci != NULL); GtkMenu * menu = GTK_MENU(gtk_menu_new()); GtkMenuItem * item = GTK_MENU_ITEM(gtk_menu_item_new_with_label("Test Label")); gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(item)); gtk_widget_show(GTK_WIDGET(item)); app_indicator_set_menu(ci, menu); g_assert(app_indicator_get_menu(ci) != NULL); GValue serverval = {0}; g_value_init(&serverval, DBUSMENU_TYPE_SERVER); g_object_get_property(G_OBJECT(ci), "dbus-menu-server", &serverval); DbusmenuServer * server = DBUSMENU_SERVER(g_value_get_object(&serverval)); g_assert(server != NULL); GValue rootval = {0}; g_value_init(&rootval, DBUSMENU_TYPE_MENUITEM); g_object_get_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_ROOT_NODE, &rootval); DbusmenuMenuitem * root = DBUSMENU_MENUITEM(g_value_get_object(&rootval)); g_assert(root != NULL); GList * children = dbusmenu_menuitem_get_children(root); g_assert(children != NULL); g_assert(g_list_length(children) == 1); const gchar * label = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(children->data), DBUSMENU_MENUITEM_PROP_LABEL); g_assert(label != NULL); g_assert(g_strcmp0(label, "Test Label") == 0); /* Interesting, eh? We need this because we send out events on the bus but they don't come back until the idle is run. So we need those events to clear before removing the object */ while (g_main_context_pending(NULL)) { g_main_context_iteration(NULL, TRUE); } g_object_unref(G_OBJECT(ci)); return; } void label_signals_cb (AppIndicator * appindicator, gchar * label, gchar * guide, gpointer user_data) { gint * label_signals_count = (gint *)user_data; (*label_signals_count)++; return; } void label_signals_check (void) { while (g_main_context_pending(NULL)) { g_main_context_iteration(NULL, TRUE); } return; } void test_libappindicator_label_signals (void) { g_test_log_set_fatal_handler (allow_warnings, NULL); gint label_signals_count = 0; AppIndicator * ci = app_indicator_new ("my-id", "my-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_assert(ci != NULL); g_assert(app_indicator_get_label(ci) == NULL); g_assert(app_indicator_get_label_guide(ci) == NULL); g_signal_connect(G_OBJECT(ci), APP_INDICATOR_SIGNAL_NEW_LABEL, G_CALLBACK(label_signals_cb), &label_signals_count); /* Shouldn't be a signal as it should be stuck in idle */ app_indicator_set_label(ci, "label", "guide"); g_assert(label_signals_count == 0); /* Should show up after idle processing */ label_signals_check(); g_assert(label_signals_count == 1); /* Shouldn't signal with no change */ label_signals_count = 0; app_indicator_set_label(ci, "label", "guide"); label_signals_check(); g_assert(label_signals_count == 0); /* Change one, we should get one signal */ app_indicator_set_label(ci, "label2", "guide"); label_signals_check(); g_assert(label_signals_count == 1); /* Change several times, one signal */ label_signals_count = 0; app_indicator_set_label(ci, "label1", "guide0"); app_indicator_set_label(ci, "label1", "guide1"); app_indicator_set_label(ci, "label2", "guide2"); app_indicator_set_label(ci, "label3", "guide3"); label_signals_check(); g_assert(label_signals_count == 1); /* Clear should signal too */ label_signals_count = 0; app_indicator_set_label(ci, NULL, NULL); label_signals_check(); g_assert(label_signals_count == 1); return; } void test_libappindicator_desktop_menu (void) { g_test_log_set_fatal_handler (allow_warnings, NULL); AppIndicator * ci = app_indicator_new ("my-id-desktop-menu", "my-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_assert(ci != NULL); g_assert(app_indicator_get_label(ci) == NULL); g_assert(app_indicator_get_label_guide(ci) == NULL); app_indicator_build_menu_from_desktop(ci, SRCDIR "/test-libappindicator.desktop", "Test Program"); GValue serverval = {0}; g_value_init(&serverval, DBUSMENU_TYPE_SERVER); g_object_get_property(G_OBJECT(ci), "dbus-menu-server", &serverval); DbusmenuServer * server = DBUSMENU_SERVER(g_value_get_object(&serverval)); g_assert(server != NULL); GValue rootval = {0}; g_value_init(&rootval, DBUSMENU_TYPE_MENUITEM); g_object_get_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_ROOT_NODE, &rootval); DbusmenuMenuitem * root = DBUSMENU_MENUITEM(g_value_get_object(&rootval)); g_assert(root != NULL); GList * children = dbusmenu_menuitem_get_children(root); g_assert(children != NULL); g_assert(g_list_length(children) == 3); g_object_unref(G_OBJECT(ci)); return; } void test_libappindicator_desktop_menu_bad (void) { g_test_log_set_fatal_handler (allow_warnings, NULL); AppIndicator * ci = app_indicator_new ("my-id-desktop-menu-bad", "my-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_assert(ci != NULL); g_assert(app_indicator_get_label(ci) == NULL); g_assert(app_indicator_get_label_guide(ci) == NULL); app_indicator_build_menu_from_desktop(ci, SRCDIR "/test-libappindicator.desktop", "Not Test Program"); GValue serverval = {0}; g_value_init(&serverval, DBUSMENU_TYPE_SERVER); g_object_get_property(G_OBJECT(ci), "dbus-menu-server", &serverval); DbusmenuServer * server = DBUSMENU_SERVER(g_value_get_object(&serverval)); g_assert(server != NULL); GValue rootval = {0}; g_value_init(&rootval, DBUSMENU_TYPE_MENUITEM); g_object_get_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_ROOT_NODE, &rootval); DbusmenuMenuitem * root = DBUSMENU_MENUITEM(g_value_get_object(&rootval)); g_assert(root != NULL); GList * children = dbusmenu_menuitem_get_children(root); g_assert(g_list_length(children) == 0); g_object_unref(G_OBJECT(ci)); return; } void test_libappindicator_props_suite (void) { g_test_add_func ("/indicator-application/libappindicator/init", test_libappindicator_init); g_test_add_func ("/indicator-application/libappindicator/init_props", test_libappindicator_init_with_props); g_test_add_func ("/indicator-application/libappindicator/init_set_props", test_libappindicator_init_set_props); g_test_add_func ("/indicator-application/libappindicator/prop_signals", test_libappindicator_prop_signals); g_test_add_func ("/indicator-application/libappindicator/set_label", test_libappindicator_set_label); g_test_add_func ("/indicator-application/libappindicator/set_menu", test_libappindicator_set_menu); g_test_add_func ("/indicator-application/libappindicator/label_signals", test_libappindicator_label_signals); g_test_add_func ("/indicator-application/libappindicator/desktop_menu", test_libappindicator_desktop_menu); g_test_add_func ("/indicator-application/libappindicator/desktop_menu_bad",test_libappindicator_desktop_menu_bad); return; } gint main (gint argc, gchar * argv[]) { gtk_init(&argc, &argv); g_test_init(&argc, &argv, NULL); /* Test suites */ test_libappindicator_props_suite(); return g_test_run (); } ./tests/test-libappindicator-status-client.c0000644000004100000410000000776413700622663021512 0ustar www-datawww-data/* Tests for the libappindicator library that are over DBus. This is the client side of those tests. Copyright 2009 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #include #include #include #include #include "../src/dbus-shared.h" static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; static gboolean watchdog_hit = TRUE; static gboolean active = FALSE; static guint toggle_count = 0; #define PASSIVE_STR "Passive" #define ACTIVE_STR "Active" #define ATTN_STR "NeedsAttention" static DBusHandlerResult dbus_reg_filter (DBusConnection * connection, DBusMessage * message, void * user_data) { if (dbus_message_is_method_call(message, NOTIFICATION_WATCHER_DBUS_ADDR, "RegisterStatusNotifierItem")) { DBusMessage * reply = dbus_message_new_method_return(message); dbus_connection_send(connection, reply, NULL); dbus_message_unref(reply); return DBUS_HANDLER_RESULT_HANDLED; } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } static DBusHandlerResult dbus_filter (DBusConnection * connection, DBusMessage * message, void * user_data) { if (!dbus_message_is_signal(message, NOTIFICATION_ITEM_DBUS_IFACE, "NewStatus")) { return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } gchar * string; DBusError derror; dbus_error_init(&derror); if (!dbus_message_get_args(message, &derror, DBUS_TYPE_STRING, &string, DBUS_TYPE_INVALID)) { g_warning("Couldn't get parameters"); dbus_error_free(&derror); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } watchdog_hit = TRUE; if (g_strcmp0(string, ACTIVE_STR) == 0) { if (active) { g_warning("Got active when already active"); passed = FALSE; return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } active = TRUE; } else { active = FALSE; } toggle_count++; if (toggle_count == 100) { g_main_loop_quit(mainloop); } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } gboolean kill_func (gpointer userdata) { if (watchdog_hit == FALSE) { g_main_loop_quit(mainloop); g_warning("Forced to Kill"); g_warning("Toggle count: %d", toggle_count); passed = FALSE; return FALSE; } watchdog_hit = FALSE; return TRUE; } gint main (gint argc, gchar * argv[]) { GError * error = NULL; DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (error != NULL) { g_error("Unable to get session bus: %s", error->message); return 1; } DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); guint nameret = 0; if (!org_freedesktop_DBus_request_name(bus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, 0, &nameret, &error)) { g_error("Unable to call to request name"); return 1; } if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { g_error("Unable to get name"); return 1; } dbus_connection_add_filter(dbus_g_connection_get_connection(session_bus), dbus_reg_filter, NULL, NULL); dbus_connection_add_filter(dbus_g_connection_get_connection(session_bus), dbus_filter, NULL, NULL); dbus_bus_add_match(dbus_g_connection_get_connection(session_bus), "type='signal',interface='" NOTIFICATION_ITEM_DBUS_IFACE "',member='NewStatus'", NULL); watchdog_hit = TRUE; g_timeout_add_seconds(20, kill_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); if (passed) { g_debug("Quiting"); return 0; } else { g_debug("Quiting as we're a failure"); return 1; } return 0; } ./tests/test-libappindicator-dbus-client.c0000644000004100000410000001723613700622663021117 0ustar www-datawww-data/* Tests for the libappindicator library that are over DBus. This is the client side of those tests. Copyright 2009 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #include #include #include #include #include #include "test-defines.h" #include "../src/dbus-shared.h" static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; static int propcount = 0; static void check_propcount (void) { if (propcount >= 5) { g_main_loop_quit(mainloop); } return; } static void prop_id_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; GError * error = NULL; GValue value = {0}; if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { g_warning("Getting ID failed: %s", error->message); g_error_free(error); passed = FALSE; check_propcount(); return; } if (g_strcmp0(TEST_ID, g_value_get_string(&value))) { g_debug("Property ID Returned: FAILED"); passed = FALSE; } else { g_debug("Property ID Returned: PASSED"); } check_propcount(); return; } static void prop_category_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; GError * error = NULL; GValue value = {0}; if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { g_warning("Getting category failed: %s", error->message); g_error_free(error); passed = FALSE; check_propcount(); return; } if (g_strcmp0(TEST_CATEGORY_S, g_value_get_string(&value))) { g_debug("Property category Returned: FAILED"); passed = FALSE; } else { g_debug("Property category Returned: PASSED"); } check_propcount(); return; } static void prop_status_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; GError * error = NULL; GValue value = {0}; if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { g_warning("Getting status failed: %s", error->message); g_error_free(error); passed = FALSE; check_propcount(); return; } if (g_strcmp0(TEST_STATE_S, g_value_get_string(&value))) { g_debug("Property status Returned: FAILED"); passed = FALSE; } else { g_debug("Property status Returned: PASSED"); } check_propcount(); return; } static void prop_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; GError * error = NULL; GValue value = {0}; if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { g_warning("Getting icon name failed: %s", error->message); g_error_free(error); passed = FALSE; check_propcount(); return; } if (g_strcmp0(TEST_ICON_NAME, g_value_get_string(&value))) { g_debug("Property icon name Returned: FAILED"); passed = FALSE; } else { g_debug("Property icon name Returned: PASSED"); } check_propcount(); return; } static void prop_attention_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; GError * error = NULL; GValue value = {0}; if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { g_warning("Getting attention icon name failed: %s", error->message); g_error_free(error); passed = FALSE; check_propcount(); return; } if (g_strcmp0(TEST_ATTENTION_ICON_NAME, g_value_get_string(&value))) { g_debug("Property attention icon name Returned: FAILED"); passed = FALSE; } else { g_debug("Property attention icon name Returned: PASSED"); } check_propcount(); return; } gboolean kill_func (gpointer userdata) { g_main_loop_quit(mainloop); g_warning("Forced to Kill"); passed = FALSE; return FALSE; } static DBusHandlerResult dbus_filter (DBusConnection * connection, DBusMessage * message, void * user_data) { if (dbus_message_is_method_call(message, NOTIFICATION_WATCHER_DBUS_ADDR, "RegisterStatusNotifierItem")) { DBusMessage * reply = dbus_message_new_method_return(message); dbus_connection_send(connection, reply, NULL); dbus_message_unref(reply); return DBUS_HANDLER_RESULT_HANDLED; } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } gint main (gint argc, gchar * argv[]) { GError * error = NULL; DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (error != NULL) { g_error("Unable to get session bus: %s", error->message); return 1; } DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); guint nameret = 0; if (!org_freedesktop_DBus_request_name(bus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, 0, &nameret, &error)) { g_error("Unable to call to request name"); return 1; } if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { g_error("Unable to get name"); return 1; } dbus_connection_add_filter(dbus_g_connection_get_connection(session_bus), dbus_filter, NULL, NULL); g_usleep(500000); DBusGProxy * props = dbus_g_proxy_new_for_name_owner(session_bus, ":1.2", "/org/ayatana/NotificationItem/my_id", DBUS_INTERFACE_PROPERTIES, &error); if (error != NULL) { g_error("Unable to get property proxy: %s", error->message); return 1; } dbus_g_proxy_begin_call (props, "Get", prop_id_cb, NULL, NULL, G_TYPE_STRING, NOTIFICATION_ITEM_DBUS_IFACE, G_TYPE_STRING, "Id", G_TYPE_INVALID); dbus_g_proxy_begin_call (props, "Get", prop_category_cb, NULL, NULL, G_TYPE_STRING, NOTIFICATION_ITEM_DBUS_IFACE, G_TYPE_STRING, "Category", G_TYPE_INVALID); dbus_g_proxy_begin_call (props, "Get", prop_status_cb, NULL, NULL, G_TYPE_STRING, NOTIFICATION_ITEM_DBUS_IFACE, G_TYPE_STRING, "Status", G_TYPE_INVALID); dbus_g_proxy_begin_call (props, "Get", prop_icon_name_cb, NULL, NULL, G_TYPE_STRING, NOTIFICATION_ITEM_DBUS_IFACE, G_TYPE_STRING, "IconName", G_TYPE_INVALID); dbus_g_proxy_begin_call (props, "Get", prop_attention_icon_name_cb, NULL, NULL, G_TYPE_STRING, NOTIFICATION_ITEM_DBUS_IFACE, G_TYPE_STRING, "AttentionIconName", G_TYPE_INVALID); g_timeout_add_seconds(2, kill_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); if (passed) { g_debug("Quiting"); return 0; } else { g_debug("Quiting as we're a failure"); return 1; } return 0; } ./tests/test-libappindicator-status-server.c0000644000004100000410000000452413700622663021531 0ustar www-datawww-data/* Tests for the libappindicator library that are over DBus. This is the server side of those tests. Copyright 2009 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #include #include #include static GMainLoop * mainloop = NULL; static gboolean active = FALSE; static guint toggle_count = 0; static GDBusConnection * connection = NULL; static gboolean times_up (gpointer unused G_GNUC_UNUSED) { g_dbus_connection_flush_sync (connection, NULL, NULL); g_clear_object (&connection); g_main_loop_quit (mainloop); return G_SOURCE_REMOVE; } gboolean toggle (gpointer userdata) { const AppIndicatorStatus new_status = active ? APP_INDICATOR_STATUS_ATTENTION : APP_INDICATOR_STATUS_ACTIVE; app_indicator_set_status (APP_INDICATOR(userdata), new_status); ++toggle_count; active = !active; if (toggle_count == 100) { g_timeout_add (100, times_up, NULL); return G_SOURCE_REMOVE; } return G_SOURCE_CONTINUE; } gint main (gint argc, gchar * argv[]) { gtk_init(&argc, &argv); g_usleep(100000); connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); g_debug("DBus Name: %s", g_dbus_connection_get_unique_name (connection)); AppIndicator * ci = app_indicator_new ("my-id", "my-icon-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_attention_icon (ci, "my-attention-icon"); GtkMenu * menu = GTK_MENU(gtk_menu_new()); GtkMenuItem * item = GTK_MENU_ITEM(gtk_menu_item_new_with_label("Label")); gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(item)); app_indicator_set_menu(ci, menu); g_timeout_add(50, toggle, ci); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); g_object_unref(G_OBJECT(ci)); g_debug("Quiting"); return 0; } ./tests/Makefile.am0000644000004100000410000001446713700622663014462 0ustar www-datawww-dataif USE_GTK3 VER=3 else VER= endif check_PROGRAMS = \ test-libappindicator \ test-libappindicator-dbus-client \ test-libappindicator-dbus-server \ test-libappindicator-status-client \ test-libappindicator-status-server \ test-libappindicator-fallback-watcher \ test-libappindicator-fallback-item \ test-simple-app TESTS = DISTCLEANFILES = $(TESTS) EXTRA_DIST = \ run-xvfb.sh \ test-libappindicator.desktop ######################################### ## test-libappindicator ######################################### test_libappindicator_SOURCES = \ test-libappindicator.c test_libappindicator_CFLAGS = \ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \ -DSRCDIR="\"$(srcdir)\"" \ -Wall -Wno-error=deprecated-declarations \ -I$(top_srcdir)/src test_libappindicator_LDADD = \ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \ $(top_builddir)/src/libappindicator$(VER).la ######################################### ## test-libappindicator-dbus-client ######################################### test_libappindicator_dbus_client_SOURCES = \ test-defines.h \ test-libappindicator-dbus-client.c test_libappindicator_dbus_client_CFLAGS = \ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \ -Wall -Wno-error=deprecated-declarations \ -I$(top_srcdir)/src test_libappindicator_dbus_client_LDADD = \ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \ $(top_builddir)/src/libappindicator$(VER).la ######################################### ## test-libappindicator-dbus-server ######################################### test_libappindicator_dbus_server_SOURCES = \ test-defines.h \ test-libappindicator-dbus-server.c test_libappindicator_dbus_server_CFLAGS = \ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \ -Wall -Wno-error=deprecated-declarations \ -I$(top_srcdir)/src test_libappindicator_dbus_server_LDADD = \ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \ $(top_builddir)/src/libappindicator$(VER).la ######################################### ## test-libappindicator-status-client ######################################### test_libappindicator_status_client_SOURCES = \ test-defines.h \ test-libappindicator-status-client.c test_libappindicator_status_client_CFLAGS = \ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \ -Wall -Wno-error=deprecated-declarations \ -I$(top_srcdir)/src test_libappindicator_status_client_LDADD = \ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \ $(top_builddir)/src/libappindicator$(VER).la ######################################### ## test-libappindicator-status-server ######################################### test_libappindicator_status_server_SOURCES = \ test-defines.h \ test-libappindicator-status-server.c test_libappindicator_status_server_CFLAGS = \ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \ -Wall -Wno-error=deprecated-declarations \ -I$(top_srcdir)/src test_libappindicator_status_server_LDADD = \ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \ $(top_builddir)/src/libappindicator$(VER).la ######################################### ## test-libappindicator-fallback ######################################### test_libappindicator_fallback_watcher_SOURCES = \ test-libappindicator-fallback-watcher.c test_libappindicator_fallback_watcher_CFLAGS = \ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \ -Wall -Wno-error=deprecated-declarations \ -I$(top_srcdir)/src test_libappindicator_fallback_watcher_LDADD = \ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \ $(top_builddir)/src/libappindicator$(VER).la test_libappindicator_fallback_item_SOURCES = \ test-libappindicator-fallback-item.c test_libappindicator_fallback_item_CFLAGS = \ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \ -Wall -Wno-error=deprecated-declarations \ -I$(top_srcdir)/src test_libappindicator_fallback_item_LDADD = \ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \ $(top_builddir)/src/libappindicator$(VER).la test-libappindicator-fallback: test-libappindicator-fallback-watcher test-libappindicator-fallback-item Makefile.am @echo "#!/bin/bash" > $@ @echo export DISPLAY= >> $@ @echo . $(srcdir)/run-xvfb.sh >> $@ @echo $(DBUS_RUNNER) --task ./test-libappindicator-fallback-watcher --task-name Watcher --ignore-return --task ./test-libappindicator-fallback-item --task-name Item >> $@ @chmod +x $@ TESTS += test-libappindicator-fallback ######################################### ## Actual tests ######################################### XML_REPORT = libappindicator-check-results.xml HTML_REPORT = libappindicator-check-results.html libappindicator-tests: libappindicator-tests-gtester Makefile.am @echo "#!/bin/bash" > $@ @echo export DISPLAY= >> $@ @echo . $(srcdir)/run-xvfb.sh >> $@ @echo export UBUNTU_MENUPROXY= >> $@ @echo $(DBUS_RUNNER) --task ./libappindicator-tests-gtester >> $@ @chmod +x $@ libappindicator-tests-gtester: test-libappindicator Makefile.am @echo "#!/bin/sh" > $@ @echo gtester -k --verbose -o=$(XML_REPORT) ./test-libappindicator >> $@ @chmod +x $@ TESTS += libappindicator-tests DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) libappindicator-tests-gtester DBUS_RUNNER=dbus-test-runner -m 300 --dbus-config /usr/share/dbus-test-runner/session.conf test-libappindicator-dbus: test-libappindicator-dbus-client test-libappindicator-dbus-server Makefile.am @echo "#!/bin/bash" > test-libappindicator-dbus @echo export DISPLAY= >> $@ @echo . $(srcdir)/run-xvfb.sh >> $@ @echo $(DBUS_RUNNER) --task ./test-libappindicator-dbus-client --task-name Client --task ./test-libappindicator-dbus-server --task-name Server --ignore-return >> test-libappindicator-dbus @chmod +x test-libappindicator-dbus TESTS += test-libappindicator-dbus XFAIL_TESTS = test-libappindicator-dbus test-libappindicator-status: test-libappindicator-status-client test-libappindicator-status-server Makefile.am @echo "#!/bin/bash" > test-libappindicator-status @echo export DISPLAY= >> $@ @echo . $(srcdir)/run-xvfb.sh >> $@ @echo $(DBUS_RUNNER) --task ./test-libappindicator-status-client --task-name Client --task ./test-libappindicator-status-server --task-name Server --ignore-return >> test-libappindicator-status @chmod +x test-libappindicator-status TESTS += test-libappindicator-status ######################################### ## test-simple-app ######################################### test_simple_app_SOURCES = \ test-simple-app.c test_simple_app_CFLAGS = \ $(TESTDEPS_CFLAGS) $(LIBRARY_CFLAGS) \ -Wall -Wno-error=deprecated-declarations \ -I$(top_srcdir)/src test_simple_app_LDADD = \ $(TESTDEPS_LIBS) $(LIBRARY_LIBS) \ $(top_builddir)/src/libappindicator$(VER).la ./tests/test-libappindicator-fallback-item.c0000644000004100000410000001063713700622663021377 0ustar www-datawww-data#include #include #include #include #include #define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE (test_libappindicator_fallback_item_get_type ()) #define TEST_LIBAPPINDICATOR_FALLBACK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItem)) #define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItemClass)) #define IS_TEST_LIBAPPINDICATOR_FALLBACK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE)) #define IS_TEST_LIBAPPINDICATOR_FALLBACK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE)) #define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItemClass)) typedef struct _TestLibappindicatorFallbackItem TestLibappindicatorFallbackItem; typedef struct _TestLibappindicatorFallbackItemClass TestLibappindicatorFallbackItemClass; struct _TestLibappindicatorFallbackItemClass { AppIndicatorClass parent_class; }; struct _TestLibappindicatorFallbackItem { AppIndicator parent; }; GType test_libappindicator_fallback_item_get_type (void); #define TEST_LIBAPPINDICATOR_FALLBACK_ITEM_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, TestLibappindicatorFallbackItemPrivate)) static void test_libappindicator_fallback_item_class_init (TestLibappindicatorFallbackItemClass *klass); static void test_libappindicator_fallback_item_init (TestLibappindicatorFallbackItem *self); static GtkStatusIcon * fallback (AppIndicator * indicator); static void unfallback (AppIndicator * indicator, GtkStatusIcon * status_icon); G_DEFINE_TYPE (TestLibappindicatorFallbackItem, test_libappindicator_fallback_item, APP_INDICATOR_TYPE); static void test_libappindicator_fallback_item_class_init (TestLibappindicatorFallbackItemClass *klass) { AppIndicatorClass * aiclass = APP_INDICATOR_CLASS(klass); aiclass->fallback = fallback; aiclass->unfallback = unfallback; } static void test_libappindicator_fallback_item_init (TestLibappindicatorFallbackItem *self) { } GMainLoop * mainloop = NULL; gboolean passed = FALSE; enum { STATE_INIT, STATE_FALLBACK, STATE_UNFALLBACK, STATE_REFALLBACK, STATE_REUNFALLBACK }; gint state = STATE_INIT; static GtkStatusIcon * fallback (AppIndicator * indicator) { g_debug("Fallback"); if (state == STATE_INIT) { state = STATE_FALLBACK; } else if (state == STATE_UNFALLBACK) { state = STATE_REFALLBACK; } else { g_debug("Error, fallback in state: %d", state); passed = FALSE; } return (GtkStatusIcon *)5; } static void unfallback (AppIndicator * indicator, GtkStatusIcon * status_icon) { g_debug("Unfallback"); if (state == STATE_FALLBACK) { state = STATE_UNFALLBACK; } else if (state == STATE_REFALLBACK) { state = STATE_REUNFALLBACK; passed = TRUE; g_main_loop_quit(mainloop); } else { g_debug("Error, unfallback in state: %d", state); passed = FALSE; } return; } gboolean kill_func (gpointer data) { g_debug("Kill Function"); g_main_loop_quit(mainloop); return FALSE; } int main (int argc, char ** argv) { gtk_init(&argc, &argv); GError * error = NULL; DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (error != NULL) { g_error("Unable to get session bus: %s", error->message); return 1; } DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); guint nameret = 0; if (!org_freedesktop_DBus_request_name(bus_proxy, "org.test", 0, &nameret, NULL)) { g_error("Unable to call to request name"); return 1; } if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { g_error("Unable to get name"); return 1; } TestLibappindicatorFallbackItem * item = g_object_new(TEST_LIBAPPINDICATOR_FALLBACK_ITEM_TYPE, "id", "test-id", "category", "Other", "icon-name", "bob", NULL); GtkWidget * menu = gtk_menu_new(); app_indicator_set_menu(APP_INDICATOR(item), GTK_MENU(menu)); g_timeout_add_seconds(20, kill_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); g_object_unref(G_OBJECT(item)); if (passed) { return 0; } else { return 1; } } ./tests/test-simple-app.c0000644000004100000410000000304713700622663015606 0ustar www-datawww-data/* Test that creates a small test app which links with libappindicator. Copyright 2009 Canonical Ltd. Authors: Ted Gould 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 warranties of MERCHANTABILITY, SATISFACTORY QUALITY, 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 . */ #include #include static GMainLoop * mainloop = NULL; int main (int argc, char ** argv) { gtk_init(&argc, &argv); GtkWidget *menu_item = gtk_menu_item_new_with_label("Test"); GtkMenu *menu = GTK_MENU(gtk_menu_new()); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); gtk_widget_show(menu_item); AppIndicator * ci = app_indicator_new("test-application", "system-shutdown", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_status(ci, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_menu(ci, menu); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); g_object_unref(G_OBJECT(ci)); g_object_unref(G_OBJECT(menu)); g_object_unref(G_OBJECT(menu_item)); g_debug("Quiting"); return 0; } ./COPYING.LGPL.2.10000644000004100000410000006363713700622663013356 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! ./bindings/0000755000004100000410000000000013700622663013045 5ustar www-datawww-data./bindings/vala/0000755000004100000410000000000013700622663013770 5ustar www-datawww-data./bindings/vala/appindicator-0.1-custom.vala0000644000004100000410000000216713700622663021124 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 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 Michal Hruby */ namespace AppIndicator { [CCode (type_check_function = "IS_APP_INDICATOR", type_id = "app_indicator_get_type ()")] public class Indicator : GLib.Object { } } // vim:et:ai:cindent:ts=2 sts=2 sw=2: ./bindings/vala/Makefile.am0000644000004100000410000000144613700622663016031 0ustar www-datawww-dataif HAVE_INTROSPECTION if HAVE_VAPIGEN SUBDIRS = . examples ######################### # VAPI Files ######################### if USE_GTK3 GTKVAPI = gtk+-3.0 VER=3 else GTKVAPI = gtk+-2.0 VER= endif vapidir = $(datadir)/vala/vapi vapiprefix = appindicator$(VER)-0.1 vapi_DATA = $(vapiprefix).vapi $(vapiprefix).deps DEPS = $(GTKVAPI) $(vapiprefix).deps: echo $(DEPS) > $@ $(vapiprefix).vapi: $(top_builddir)/src/AppIndicator$(VER)-0.1.gir \ $(top_builddir)/src/AppIndicator$(VER)-0.1.metadata \ appindicator-0.1-custom.vala \ $(vapiprefix).deps $(VALA_API_GEN) --library=$(vapiprefix) --girdir=$(srcdir)/src \ $< $(srcdir)/appindicator-0.1-custom.vala CLEANFILES = $(vapi_DATA) endif endif EXTRA_DIST = \ appindicator-0.1-custom.vala ./bindings/vala/examples/0000755000004100000410000000000013700622663015606 5ustar www-datawww-data./bindings/vala/examples/indicator-example.vala0000644000004100000410000000343213700622663022062 0ustar www-datawww-data/* * Copyright 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 warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, 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 . * * Authors: * Marco Trevisan (Treviño) */ using Gtk; using AppIndicator; public class IndicatorExample { public static int main(string[] args) { Gtk.init(ref args); var win = new Window(); win.title = "Indicator Test"; win.resize(200, 200); win.destroy.connect(Gtk.main_quit); var label = new Label("Hello, world!"); win.add(label); var indicator = new Indicator(win.title, "indicator-messages", IndicatorCategory.APPLICATION_STATUS); if (!(indicator is Indicator)) return -1; indicator.set_status(IndicatorStatus.ACTIVE); indicator.set_attention_icon("indicator-messages-new"); var menu = new Gtk.Menu(); var item = new Gtk.MenuItem.with_label("Foo"); item.activate.connect(() => { indicator.set_status(IndicatorStatus.ATTENTION); }); item.show(); menu.append(item); var bar = item = new Gtk.MenuItem.with_label("Bar"); item.show(); item.activate.connect(() => { indicator.set_status(IndicatorStatus.ACTIVE); }); menu.append(item); indicator.set_menu(menu); indicator.set_secondary_activate_target(bar); win.show_all(); Gtk.main(); return 0; } } ./bindings/vala/examples/Makefile.am0000644000004100000410000000137613700622663017651 0ustar www-datawww-dataif USE_GTK3 VER=3 else VER= endif VALAFILES = indicator-example.vala EXTRA_DIST = $(VALAFILES) VALAFLAGS = \ --pkg appindicator$(VER)-0.1 \ --vapidir=$(top_builddir)/bindings/vala \ --save-temps if HAVE_VALAC BUILT_SOURCES = indicator-example.c indicator-example.c: $(VALAFILES) Makefile.am $(VALAC) $(VALAFLAGS) -C $< -o $@ $(SED) -i "s|#include\s*<\s*libappindicator/app-indicator.h\s*>||g" $@ nodist_indicator_example_SOURCES = indicator-example.c indicator_example_CFLAGS = \ $(LIBRARY_CFLAGS) \ -Wall \ -I$(top_srcdir)/src \ -include $(top_srcdir)/src/app-indicator.h indicator_example_LDADD = \ $(LIBRARY_LIBS) \ $(top_builddir)/src/libappindicator$(VER).la check_PROGRAMS = indicator-example CLEANFILES = \ *.c \ indicator-example endif ./bindings/mono/0000755000004100000410000000000013700622663014015 5ustar www-datawww-data./bindings/mono/AssemblyInfo.cs0000644000004100000410000000217213700622663016741 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 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 warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, 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 . * * Authors: * Cody Russell */ using System.Reflection; [assembly: AssemblyTitle ("Application Indicators")] [assembly: AssemblyDescription ("Ubuntu Application Indicators")] [assembly: AssemblyConfiguration ("")] [assembly: AssemblyCompany ("Canonical, Ltd.")] [assembly: AssemblyProduct ("Ubuntu")] [assembly: AssemblyCopyright ("© 2010 Canonical, Ltd.")] [assembly: AssemblyTrademark ("")] [assembly: AssemblyCulture ("")] [assembly: AssemblyVersion ("0.2")] ./bindings/mono/ApplicationIndicator.custom0000644000004100000410000000137213700622663021354 0ustar www-datawww-data[DllImport ("appindicator.dll")] static extern int app_indicator_get_status (IntPtr i); [DllImport ("appindicator.dll")] static extern int app_indicator_get_category (IntPtr i); [DllImport ("appindicator.dll")] static extern void app_indicator_set_status (IntPtr i, int s); [GLib.Property ("status")] public Status Status { get { return (Status) app_indicator_get_status (Handle); } set { app_indicator_set_status (Handle, (int) value); } } [GLib.Property ("category")] public Category Category { get { return (Category) app_indicator_get_category (Handle); } } ./bindings/mono/appindicator-sharp-0.1.pc.in0000644000004100000410000000060213700622663021030 0ustar www-datawww-dataprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ assemblies_dir=${prefix}/lib/cli/appindicator-sharp-0.1 Name: appindicator-sharp Description: application indicators for .NET Version: @VERSION@ Libraries: ${assemblies_dir}/appindicator-sharp.dll ${assemblies_dir}/appindicator-sharp.dll.config Requires: gtk-sharp-2.0 Cflags: Libs: -r:${assemblies_dir}/appindicator-sharp.dll ./bindings/mono/appindicator-sharp.snk0000644000004100000410000000112413700622663020320 0ustar www-datawww-data$RSA2 U 5~rۿBNa @X< tmmYcTX}K0tM,ފ~s/>H٤6̭bº8|(Hܚ4haHPc{X}1""C#y*Ì=d"~'!d{;<{0b9*gmNGhٜQTr] y-Tt$34ҏQ{IǥWu=4,.o En/㝶R~}{yo뿈8G"zu]/23=`}Py?ςp?Xwh4LNm¬߿f Bu/4=f>4ҨSfF0pX묤(A9Ib*b1LՓjZ'}EbI*QExsfuقգ'Ey&~Y E8z ]VO)P!;:uV5? .;k+*9rn\oٍu 5zYmB(./bindings/mono/TestIndicator.cs0000644000004100000410000000506213700622663017123 0ustar www-datawww-data/* * Copyright 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 warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, 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 . * * Authors: * Cody Russell */ using System; using GLib; using Gtk; using AppIndicator; using NUnit.Framework; namespace Ayatana.AppIndicator.Test { [TestFixture] public class IndicatorTest { ApplicationIndicator indicator; private void Update () { while (MainContext.Pending ()) MainContext.Iteration(true); } [SetUp] public void Init () { Application.Init (); Console.WriteLine ("Init()"); indicator = new ApplicationIndicator ("my-id", "my-name", Category.ApplicationStatus); Console.WriteLine ("Created indicator"); Update(); } [Test] public void TestProperties () { Console.WriteLine ("TestProperties()"); Assert.AreNotSame (indicator, null); Assert.AreEqual (indicator.IconName, "my-name"); Assert.AreEqual (indicator.ID, "my-id"); Assert.AreEqual (indicator.Status, Category.ApplicationStatus); Console.WriteLine ("End.."); } [Test] public void TestSetProperties () { Console.WriteLine ("TestSetProperties"); indicator.Status = Status.Attention; indicator.AttentionIconName = "my-attention-name"; Assert.AreEqual (indicator.Status, Status.Attention); Assert.AreEqual (indicator.AttentionIconName, "my-attention-name"); Console.WriteLine ("End.."); } } }./bindings/mono/app-indicator.sources.xml.in0000644000004100000410000000065513700622663021366 0ustar www-datawww-data @top_builddir@/bindings/mono/app-indicator.c @top_builddir@/src/app-indicator-enum-types.c @top_builddir@/src/app-indicator-enum-types.h @top_srcdir@/src/app-indicator.h ./bindings/mono/policy.0.0.appindicator-sharp.config.in0000644000004100000410000000053713700622663023200 0ustar www-datawww-data ./bindings/mono/libappindicator-api.metadata0000644000004100000410000001606013700622663021435 0ustar www-datawww-data ApplicationIndicator NewAttentionIcon new-attention-icon NewStatus new-status NewLabel new-label NewAccessibleDesc new-accessible-desc ConnectionChanged connection-changed ScrollEvent scroll-event NewIcon new-icon NewIconThemePath new-icon-theme-path ID true true IconName AttentionIconName IconThemePath Menu GtkMenu* Connected Label LabelGuide AccessibleDesc OrderingIndex SetMenu id icon-name category id icon-name category icon-theme-path ./bindings/mono/appindicator-sharp.dll.config.in0000644000004100000410000000071513700622663022156 0ustar www-datawww-data ./bindings/mono/policy.0.1.appindicator-sharp.config.in0000644000004100000410000000055213700622663023176 0ustar www-datawww-data ./bindings/mono/Makefile.am0000644000004100000410000001223313700622663016052 0ustar www-datawww-dataSUBDIRS = . examples pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = appindicator-sharp-0.1.pc if BUILD_MONO_TEST TEST = AppIndicator.Test.dll endif API = libappindicator-api.xml MIDDLE_API = libappindicator-api.middle RAW_API = libappindicator-api.raw METADATA = libappindicator-api.metadata ASSEMBLY_NAME = appindicator-sharp ASSEMBLY_VERSION = 0.2.0.0 ASSEMBLY = $(ASSEMBLY_NAME).dll POLICY = policy.$(POLICY_VERSION).$(ASSEMBLY_NAME) POLICY_VERSION = 0.0 DLLPOLICY = $(POLICY).dll POLICY1 = policy.$(POLICY1_VERSION).$(ASSEMBLY_NAME) POLICY1_VERSION = 0.1 DLLPOLICY1 = $(POLICY1).dll WRAPPER_FREE_BINDING_SRC = $(top_srcdir)/src/app-indicator.c WRAPPER_FREE_BINDING = app-indicator.c TARGET = \ $(ASSEMBLY) \ $(ASSEMBLY).config \ $(DLLPOLICY) \ $(POLICY).config \ $(DLLPOLICY1) \ $(POLICY1).config assemblydir = $(libdir)/cli/appindicator-sharp-0.1 assembly_DATA = $(TARGET) CLEANFILES = \ $(ASSEMBLY) \ $(ASSEMBLY).mdb \ generated-stamp \ generated/*.cs \ $(API) \ $(MIDDLE_API) \ $(RAW_API) \ $(DLLPOLICY) \ $(DLLPOLICY1) \ $(WRAPPER_FREE_BINDING) \ $(POLICY).config \ $(POLICY1).config if BUILD_MONO_TEST CLEANFILES += $(TEST) endif DISTCLEANFILES = $(ASSEMBLY).config if BUILD_MONO_TEST TEST_SOURCES = TestIndicator.cs endif customs = ApplicationIndicator.custom EXTRA_DIST = \ AssemblyInfo.cs \ $(RAW_API) \ $(METADATA) \ appindicator-sharp-0.1.pc.in \ appindicator-sharp.dll.config.in \ app-indicator.sources.xml.in \ $(ASSEMBLY_NAME).snk \ $(POLICY).config.in \ $(POLICY1).config.in \ $(customs) if BUILD_MONO_TEST EXTRA_DIST += $(TEST_SOURCES) endif GACUTIL_FLAGS=-package $(ASSEMBLY_NAME) -root $(DESTDIR)$(prefix)/lib references = $(GTK_SHARP_LIBS) if BUILD_MONO_TEST test_references = $(GTK_SHARP_LIBS) $(NUNIT_LIBS) $(MONO_NUNIT_LIBS) -r:$(ASSEMBLY) endif $(RAW_API): app-indicator.sources.xml $(WRAPPER_FREE_BINDING) $(GAPI_PARSER) app-indicator.sources.xml $(WRAPPER_FREE_BINDING): $(WRAPPER_FREE_BINDING_SRC) sed '/signals\[X_NEW_LABEL\] /,+6d' $(WRAPPER_FREE_BINDING_SRC) > $(WRAPPER_FREE_BINDING) $(MIDDLE_API): $(METADATA) $(RAW_API) cp $(RAW_API) $(MIDDLE_API) chmod u+w $(MIDDLE_API) @if test -n '$(METADATA)'; then \ echo "$(GAPI_FIXUP) --api=$(MIDDLE_API) --metadata=$(srcdir)/$(METADATA)"; \ $(GAPI_FIXUP) --api=$(MIDDLE_API) --metadata=$(srcdir)/$(METADATA); \ fi $(API): $(MIDDLE_API) Makefile.am sed -e "s|PROP_ID_S|id|" \ -e "s|PROP_STATUS_S|Status|" \ -e "s|PROP_STATUS_S|status|" \ -e "s|PROP_CATEGORY_S|Category|" \ -e "s|PROP_CATEGORY_S|category|" \ -e "s|PROP_ICON_NAME_S|icon-name|" \ -e "s|PROP_ICON_DESC_S|IconDesc|" \ -e "s|PROP_ICON_DESC_S|icon-desc|" \ -e "s|PROP_ATTENTION_ICON_NAME_S|AttentionIconName|" \ -e "s|PROP_ATTENTION_ICON_NAME_S|attention-icon-name|" \ -e "s|PROP_ATTENTION_ICON_DESC_S|AttentionIconDesc|" \ -e "s|PROP_ATTENTION_ICON_DESC_S|attention-icon-desc|" \ -e "s|PROP_ICON_THEME_PATH_S|icon-theme-path|" \ -e "s|PROP_MENU_S|menu|" \ -e "s|PROP_CONNECTED_S|connected|" \ -e "s|PROP_LABEL_S|label|" \ -e "s|PROP_LABEL_GUIDE_S|label-guide|" \ -e "s|PROP_ORDERING_INDEX_S|ordering-index|" \ -e "s|PROP_DBUS_MENU_SERVER_S|DbusMenuServer|" \ -e "s|PROP_DBUS_MENU_SERVER_S|dbus-menu-server|" \ -e "s|PROP_TITLE_S|Title|" \ -e "s|PROP_TITLE_S|title|" \ $< > $@ api_includes = $(GTK_SHARP_CFLAGS) build_customs = $(addprefix $(srcdir)/, $(customs)) generated-stamp: $(API) $(build_customs) rm -f generated/* && \ $(GAPI_CODEGEN) --generate $(API) $(api_includes) \ --customdir=$(srcdir) \ --outdir=generated --assembly-name=$(ASSEMBLY_NAME) \ && touch generated-stamp $(ASSEMBLY): generated-stamp $(srcdir)/AssemblyInfo.cs @rm -f $(ASSEMBLY).mdb $(CSC) $(CSFLAGS) -keyfile:$(srcdir)/$(ASSEMBLY_NAME).snk -nowarn:0169,0612,0618 -unsafe -out:$(ASSEMBLY) -target:library $(references) $(builddir)/$(GENERATED_SOURCES) $(srcdir)/AssemblyInfo.cs install-data-local: echo "$(GACUTIL) -i $(ASSEMBLY_NAME).dll $(GACUTIL_FLAGS)"; \ $(GACUTIL) -i $(ASSEMBLY_NAME).dll $(GACUTIL_FLAGS) || exit 1; echo "$(GACUTIL) -i $(DLLPOLICY) $(GACUTIL_FLAGS)"; \ $(GACUTIL) -i $(DLLPOLICY) $(GACUTIL_FLAGS) || exit 1; uninstall-local: echo "$(GACUTIL) -u $(ASSEMBLY_NAME) $(GACUTIL_FLAGS)"; \ $(GACUTIL) -u $(ASSEMBLY_NAME) $(GACUTIL_FLAGS) || exit 1; echo "$(GACUTIL) -u $(DLLPOLICY) $(GACUTIL_FLAGS)"; \ $(GACUTIL) -u $(POLICY) $(GACUTIL_FLAGS) || exit 1; if BUILD_MONO_TEST $(TEST): $(ASSEMBLY) $(TEST_SOURCES) $(CSC) -out:$(TEST) -target:library $(test_references) $(srcdir)/$(TEST_SOURCES) all: $(TEST) endif $(POLICY).config: $(POLICY).config.in Makefile sed -e "s|@ASSEMBLY_NAME@|$(ASSEMBLY_NAME)|" \ -e "s|@ASSEMBLY_VERSION@|$(ASSEMBLY_VERSION)|g" \ $< > $@ $(DLLPOLICY): $(POLICY).config $(ASSEMBLY_NAME).snk Makefile $(AL) -link:$(POLICY).config -out:$(DLLPOLICY) -keyfile:$(srcdir)/$(ASSEMBLY_NAME).snk $(POLICY1).config: $(POLICY1).config.in Makefile sed -e "s|@ASSEMBLY_NAME@|$(ASSEMBLY_NAME)|" \ -e "s|@ASSEMBLY_VERSION@|$(ASSEMBLY_VERSION)|g" \ $< > $@ $(DLLPOLICY1): $(POLICY1).config $(ASSEMBLY_NAME).snk Makefile $(AL) -link:$(POLICY1).config -out:$(DLLPOLICY1) -keyfile:$(srcdir)/$(ASSEMBLY_NAME).snk ./bindings/mono/examples/0000755000004100000410000000000013700622663015633 5ustar www-datawww-data./bindings/mono/examples/indicator-example.in0000755000004100000410000000015413700622663021573 0ustar www-datawww-data#!/bin/sh MONO_PATH=@top_builddir@/bindings/mono @top_builddir@/bindings/mono/examples/IndicatorExample.exe ./bindings/mono/examples/IndicatorExample.cs0000644000004100000410000000367013700622663021420 0ustar www-datawww-data/* * Copyright 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 warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, 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 . * * Authors: * Cody Russell */ using Gtk; using AppIndicator; public class IndicatorExample { public static void Main () { Application.Init (); Window win = new Window ("Test"); win.Resize (200, 200); Label label = new Label (); label.Text = "Hello, world!"; win.Add (label); ApplicationIndicator indicator = new ApplicationIndicator ("Example", "applications-microblogging-panel", Category.ApplicationStatus); indicator.Status = Status.Attention; Menu menu = new Menu (); var foo = new MenuItem ("Foo"); menu.Append (foo); foo.Activated += delegate { System.Console.WriteLine ("Foo item has been activated"); }; menu.Append (new MenuItem ("Bar")); indicator.Menu = menu; indicator.Menu.ShowAll (); indicator.SecondaryActivateTarget = foo; win.ShowAll (); Application.Run (); } } ./bindings/mono/examples/Makefile.am0000644000004100000410000000052213700622663017666 0ustar www-datawww-dataASSEMBLY = IndicatorExample.exe CSFILES = IndicatorExample.cs CLEANFILES = $(ASSEMBLY) EXTRA_DIST = $(CSFILES) references = $(GTK_SHARP_LIBS) -r:$(top_builddir)/bindings/mono/appindicator-sharp.dll $(ASSEMBLY): $(CSFILES) Makefile.am $(CSC) $(CSFLAGS) -out:$(ASSEMBLY) -target:exe $(references) $(srcdir)/$(CSFILES) all: $(ASSEMBLY) ./bindings/Makefile.am0000644000004100000410000000012013700622663015072 0ustar www-datawww-dataSUBDIRS = if USE_GTK3 SUBDIRS += vala endif if HAS_MONO SUBDIRS += mono endif ./Makefile.am0000644000004100000410000000262413700622663013310 0ustar www-datawww-dataACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} SUBDIRS = \ src \ bindings \ docs # FIXME: Disabled, vala error # example if WANT_TESTS SUBDIRS += tests endif EXTRA_DIST = \ m4/introspection.m4 \ gtk-doc.make \ omf.make \ xmldocs.make \ autogen.sh \ COPYING.LGPL.2.1 \ ChangeLog DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-localinstall --enable-introspection dist-hook: @if test -d "$(top_srcdir)/.bzr"; \ then \ echo Creating ChangeLog && \ ( cd "$(top_srcdir)" && \ echo '# Generated by Makefile. Do not edit.'; echo; \ $(top_srcdir)/missing --run bzr log --gnu-changelog ) > ChangeLog.tmp \ && mv -f ChangeLog.tmp $(top_distdir)/ChangeLog \ || (rm -f ChangeLog.tmp; \ echo Failed to generate ChangeLog >&2 ); \ else \ echo Failed to generate ChangeLog: not a branch >&2; \ fi @if test -d "$(top_srcdir)/.bzr"; \ then \ echo Creating AUTHORS && \ ( cd "$(top_srcdir)" && \ echo '# Generated by Makefile. Do not edit.'; echo; \ $(top_srcdir)/missing --run bzr log --long --levels=0 | grep -e "^\s*author:" -e "^\s*committer:" | cut -d ":" -f 2 | cut -d "<" -f 1 | sort -u) > AUTHORS.tmp \ && mv -f AUTHORS.tmp $(top_distdir)/AUTHORS \ || (rm -f AUTHORS.tmp; \ echo Failed to generate AUTHORS >&2 ); \ else \ echo Failed to generate AUTHORS: not a branch >&2; \ fi include $(top_srcdir)/Makefile.am.coverage ./m4/0000755000004100000410000000000013700622663011570 5ustar www-datawww-data./m4/gcov.m40000644000004100000410000000471713700622663013001 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]) 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) case `$SHTOOL path $CC` in *ccache*[)] gcc_ccache=yes;; *[)] gcc_ccache=no;; esac 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" 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 -fprofile-arcs -ftest-coverage" COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-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 ./m4/introspection.m40000644000004100000410000000661413700622663014741 0ustar www-datawww-datadnl -*- mode: autoconf -*- dnl Copyright 2009 Johan Dahlin dnl dnl This file is free software; the author(s) gives unlimited dnl permission to copy and/or distribute it, with or without dnl modifications, as long as this notice is preserved. dnl # serial 1 m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], [ AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first AC_BEFORE([LT_INIT],[$0])dnl setup libtool first dnl enable/disable introspection m4_if([$2], [require], [dnl enable_introspection=yes ],[dnl AC_ARG_ENABLE(introspection, AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], [Enable introspection for this build]),, [enable_introspection=auto]) ])dnl AC_MSG_CHECKING([for gobject-introspection]) dnl presence/version checking AS_CASE([$enable_introspection], [no], [dnl found_introspection="no (disabled, use --enable-introspection to enable)" ],dnl [yes],[dnl PKG_CHECK_EXISTS([gobject-introspection-1.0],, AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) ],dnl [auto],[dnl PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) ],dnl [dnl AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) ])dnl AC_MSG_RESULT([$found_introspection]) INTROSPECTION_SCANNER= INTROSPECTION_COMPILER= INTROSPECTION_GENERATE= INTROSPECTION_GIRDIR= INTROSPECTION_TYPELIBDIR= if test "x$found_introspection" = "xyes"; then INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection fi AC_SUBST(INTROSPECTION_SCANNER) AC_SUBST(INTROSPECTION_COMPILER) AC_SUBST(INTROSPECTION_GENERATE) AC_SUBST(INTROSPECTION_GIRDIR) AC_SUBST(INTROSPECTION_TYPELIBDIR) AC_SUBST(INTROSPECTION_CFLAGS) AC_SUBST(INTROSPECTION_LIBS) AC_SUBST(INTROSPECTION_MAKEFILE) AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") ]) dnl Usage: dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], [ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) ]) dnl Usage: dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], [ _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) ]) ./AUTHORS0000644000004100000410000000000013700622663012306 0ustar www-datawww-data