diff options
-rw-r--r-- | gio/giomm.h | 1 | ||||
-rw-r--r-- | gio/giomm/meson.build | 3 | ||||
-rw-r--r-- | gio/src/appinfomonitor.ccg | 22 | ||||
-rw-r--r-- | gio/src/appinfomonitor.hg | 72 | ||||
-rw-r--r-- | gio/src/filelist.am | 3 | ||||
-rw-r--r-- | tools/m4/convert_gio.m4 | 1 |
6 files changed, 100 insertions, 2 deletions
diff --git a/gio/giomm.h b/gio/giomm.h index 007cb27e..fe33c51e 100644 --- a/gio/giomm.h +++ b/gio/giomm.h @@ -25,6 +25,7 @@ #include <giomm/actiongroup.h> #include <giomm/actionmap.h> #include <giomm/appinfo.h> +#include <giomm/appinfomonitor.h> #include <giomm/applaunchcontext.h> #include <giomm/application.h> #include <giomm/applicationcommandline.h> diff --git a/gio/giomm/meson.build b/gio/giomm/meson.build index fc508246..faaeb9b5 100644 --- a/gio/giomm/meson.build +++ b/gio/giomm/meson.build @@ -29,8 +29,9 @@ giomm_any_hg_ccg_basenames = [ 'action', 'actiongroup', 'actionmap', - 'applaunchcontext', 'appinfo', + 'appinfomonitor', + 'applaunchcontext', 'application', 'applicationcommandline', 'asyncinitable', 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 \ diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4 index a8498630..2a5ca578 100644 --- a/tools/m4/convert_gio.m4 +++ b/tools/m4/convert_gio.m4 @@ -93,6 +93,7 @@ _CONVERSION(`const Glib::RefPtr<ActionGroup>&',`GActionGroup*',__CONVERT_REFPTR_ # AppInfo _CONVERSION(`GAppInfo*',`Glib::RefPtr<AppInfo>',`Glib::wrap($3)') +_CONVERSION(`GAppInfoMonitor*',`Glib::RefPtr<AppInfoMonitor>',`Glib::wrap($3)') _CONVERSION(`const Glib::RefPtr<AppLaunchContext>&',`GAppLaunchContext*',__CONVERT_REFPTR_TO_P) _CONVERSION(`GAppLaunchContext*',`const Glib::RefPtr<AppLaunchContext>&',Glib::wrap($3)) _CONVERSION(`const Glib::RefPtr<AppInfo>&',`GAppInfo*',__CONVERT_REFPTR_TO_P) |