summaryrefslogtreecommitdiff
path: root/pidgin/gtkidle.c
diff options
context:
space:
mode:
authorGary Kramlich <grim@reaperworld.com>2021-10-22 03:33:32 -0500
committerGary Kramlich <grim@reaperworld.com>2021-10-22 03:33:32 -0500
commitf1da8613611d1ff9b13d3fca3f33d03a944b039d (patch)
tree0b8d5b07f2f79f2039f9457480a7c12ab0004f5d /pidgin/gtkidle.c
parent0bc65db10522f7cb872027ada13b1cfd5fc39b87 (diff)
downloadpidgin-f1da8613611d1ff9b13d3fca3f33d03a944b039d.tar.gz
Replace PurpleIdleUiOps with the PurpleIdleUi Interface
This continues our path down replacing the UiOps with Interfaces so that developers can write user interfaces in other languages using gobject introspection. Testing Done: Ran pidgin3 and set it to auto idle after 1 minute of system idle time. This attempted to query xscreen saver, but something didn't work there, but that's been happening before this change. Not sure if it's my system or the code just needs fixing. Ran finch3 set idle time to 1 minute and verified that it set me to away after that minute. I also used the libpurple idle time for both pidgin3 and finch3 and verified they continued to work as well. Reviewed at https://reviews.imfreedom.org/r/1091/
Diffstat (limited to 'pidgin/gtkidle.c')
-rw-r--r--pidgin/gtkidle.c66
1 files changed, 44 insertions, 22 deletions
diff --git a/pidgin/gtkidle.c b/pidgin/gtkidle.c
index 7139e975fc..c1afca28b4 100644
--- a/pidgin/gtkidle.c
+++ b/pidgin/gtkidle.c
@@ -1,9 +1,6 @@
/*
- * pidgin
- *
- * Pidgin is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
+ * Pidgin - Universal Chat Client
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
*
* 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
@@ -16,9 +13,7 @@
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- *
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
@@ -46,6 +41,10 @@
#include <purple.h>
+struct _PidginIdle {
+ GObject parent;
+};
+
#if !defined(HAVE_IOKIT) && !defined(_WIN32)
typedef struct {
gchar *bus_name;
@@ -70,6 +69,10 @@ static const PidginDBusScreenSaverInfo screensavers[] = {
};
#endif /* !HAVE_IOKIT && !_WIN32 */
+/******************************************************************************
+ * PurpleIdleUI Implementation
+ *****************************************************************************/
+
/*
* pidgin_get_time_idle:
*
@@ -83,8 +86,7 @@ static const PidginDBusScreenSaverInfo screensavers[] = {
* Returns: The number of seconds the user has been idle.
*/
static time_t
-pidgin_get_time_idle(void)
-{
+pidgin_idle_get_idle_time(PurpleIdleUi *ui) {
# ifdef HAVE_IOKIT
/* Query the IOKit API */
double idleSeconds = -1;
@@ -190,17 +192,37 @@ pidgin_get_time_idle(void)
# endif /* !HAVE_IOKIT */
}
-static PurpleIdleUiOps ui_ops =
-{
- pidgin_get_time_idle,
- NULL,
- NULL,
- NULL,
- NULL
-};
+static void
+pidgin_idle_purple_ui_init(PurpleIdleUiInterface *iface) {
+ iface->get_idle_time = pidgin_idle_get_idle_time;
+}
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+G_DEFINE_TYPE_EXTENDED(
+ PidginIdle,
+ pidgin_idle,
+ G_TYPE_OBJECT,
+ 0,
+ G_IMPLEMENT_INTERFACE(
+ PURPLE_TYPE_IDLE_UI,
+ pidgin_idle_purple_ui_init
+ )
+);
+
+static void
+pidgin_idle_init(PidginIdle *idle) {
+}
+
+static void
+pidgin_idle_class_init(PidginIdleClass *klass) {
+}
-PurpleIdleUiOps *
-pidgin_idle_get_ui_ops()
-{
- return &ui_ops;
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+PurpleIdleUi *
+pidgin_idle_new(void) {
+ return g_object_new(PIDGIN_TYPE_IDLE, NULL);
}