/* Copyright (C) 2022 The giomm Development Team
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

_CONFIGINCLUDE(giommconfig.h)

#include <glibmm/object.h>

_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gio
{

/** Monitor application information for changes.
 *
 * %Gio::AppInfoMonitor is a very simple object used for monitoring the app
 * info database for changes (ie: newly installed or removed
 * applications).
 *
 * Call get() to get a %Gio::AppInfoMonitor and connect to signal_changed().
 *
 * In the usual case, applications should try to make note of the change
 * (doing things like invalidating caches) but not act on it. In
 * particular, applications should avoid making calls to Gio::AppInfo APIs
 * in response to the change signal, deferring these until the time that
 * the data is actually required. The exception to this case is when
 * application information is actually being displayed on the screen
 * (eg: during a search or when the list of all applications is shown).
 * The reason for this is that changes to the list of installed
 * applications often come in groups (like during system updates) and
 * rescanning the list on every change is pointless and expensive.
 *
 * @newin{2,72}
 */
class GIOMM_API AppInfoMonitor : public Glib::Object
{
  _CLASS_GOBJECT(AppInfoMonitor, GAppInfoMonitor, G_APP_INFO_MONITOR, Glib::Object, GObject, , , GIOMM_API)

public:
  /** Gets the %AppInfoMonitor for the current thread-default main context.
   *
   * The %AppInfoMonitor will emit a "changed" signal in the
   * thread-default main context whenever the list of installed
   * applications (as reported by Gio::AppInfo::get_all()) may have changed.
   *
   * You must only drop the last reference on the return value from under
   * the same main context as you created it.
   *
   * @newin{2,72}
   *
   * @return A reference to a %Gio::AppInfoMonitor.
   */
  _WRAP_METHOD(static Glib::RefPtr<AppInfoMonitor> get(), g_app_info_monitor_get, newin "2,72")

  // no_default_handler because the wrapped C signal has no default handler.
  _WRAP_SIGNAL(void changed(), "changed", no_default_handler, newin "2,72")
};

} // namespace Gio
