diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2022-02-16 13:33:48 +0100 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2022-02-16 13:33:48 +0100 |
commit | 2fe9dbd84c7d5fc7acd9381c5599d8ba85d9446a (patch) | |
tree | c37f7413021df022f0b1ff1775299025b2cd3264 /gio/src | |
parent | 7b811a0be824675f31a422d40a75bbb5d10e32ad (diff) | |
download | glibmm-2fe9dbd84c7d5fc7acd9381c5599d8ba85d9446a.tar.gz |
Add Gio::AppInfoMonitor
Fixes #97
Diffstat (limited to 'gio/src')
-rw-r--r-- | gio/src/appinfomonitor.ccg | 22 | ||||
-rw-r--r-- | gio/src/appinfomonitor.hg | 72 | ||||
-rw-r--r-- | gio/src/filelist.am | 3 |
3 files changed, 96 insertions, 1 deletions
diff --git a/gio/src/appinfomonitor.ccg b/gio/src/appinfomonitor.ccg new file mode 100644 index 00000000..f6042447 --- /dev/null +++ b/gio/src/appinfomonitor.ccg @@ -0,0 +1,22 @@ +/* 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/>. + */ + +#include <gio/gio.h> + +namespace Gio +{ + +} // namespace Gio diff --git a/gio/src/appinfomonitor.hg b/gio/src/appinfomonitor.hg new file mode 100644 index 00000000..0f6fcf38 --- /dev/null +++ b/gio/src/appinfomonitor.hg @@ -0,0 +1,72 @@ +/* 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 diff --git a/gio/src/filelist.am b/gio/src/filelist.am index 38f92d85..8f0f297f 100644 --- a/gio/src/filelist.am +++ b/gio/src/filelist.am @@ -14,8 +14,9 @@ giomm_files_any_hg = \ action.hg \ actiongroup.hg \ actionmap.hg \ - applaunchcontext.hg \ appinfo.hg \ + appinfomonitor.hg \ + applaunchcontext.hg \ application.hg \ applicationcommandline.hg \ asyncinitable.hg \ |