Mercurial > pidgin.yaz
changeset 15740:73219517f583
gntgaim idle reporting, this fixes idle return
author | Richard Nelson <wabz@pidgin.im> |
---|---|
date | Tue, 27 Feb 2007 04:11:46 +0000 |
parents | 1d0dc6ecfa0d |
children | 2273694a865d |
files | console/Makefile.am console/gntgaim.c console/gntidle.c console/gntidle.h console/libgnt/gntwm.c console/libgnt/gntwm.h |
diffstat | 6 files changed, 118 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/console/Makefile.am Mon Feb 26 16:29:05 2007 +0000 +++ b/console/Makefile.am Tue Feb 27 04:11:46 2007 +0000 @@ -17,6 +17,7 @@ gntdebug.c \ gntft.c \ gntgaim.c \ + gntidle.c \ gntnotify.c \ gntplugin.c \ gntpounce.c \ @@ -33,6 +34,7 @@ gntdebug.h \ gntft.h \ gntgaim.h \ + gntidle.h \ gntnotify.h \ gntplugin.h \ gntpounce.h \
--- a/console/gntgaim.c Mon Feb 26 16:29:05 2007 +0000 +++ b/console/gntgaim.c Tue Feb 27 04:11:46 2007 +0000 @@ -41,6 +41,7 @@ #include "gntgaim.h" #include "gntprefs.h" #include "gntui.h" +#include "gntidle.h" #define _GNU_SOURCE #include <getopt.h> @@ -339,6 +340,7 @@ gaim_core_set_ui_ops(gnt_core_get_ui_ops()); gaim_eventloop_set_ui_ops(gnt_eventloop_get_ui_ops()); + gaim_idle_set_ui_ops(gg_idle_get_ui_ops()); path = g_build_filename(gaim_user_dir(), "plugins", NULL); gaim_plugins_add_search_path(path);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/gntidle.c Tue Feb 27 04:11:46 2007 +0000 @@ -0,0 +1,45 @@ +/* + * gaim + * + * Gaim 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. + * + * 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 of the License, 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 + * + */ + +#include "internal.h" +#include "gntidle.h" +#include "gntwm.h" + +#include "idle.h" + +static time_t +gg_get_idle_time() +{ + return gnt_wm_get_idle_time(); +} + +static GaimIdleUiOps ui_ops = +{ + gg_get_idle_time +}; + +GaimIdleUiOps * +gg_idle_get_ui_ops() +{ + return &ui_ops; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/gntidle.h Tue Feb 27 04:11:46 2007 +0000 @@ -0,0 +1,44 @@ +/** + * @file gntidle.h GNT Idle API + * @ingroup gntui + * + * gaim + * + * 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. + * + * 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 of the License, 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 + */ +#ifndef _GNT_IDLE_H_ +#define _GNT_IDLE_H_ + +#include "idle.h" + +/**************************************************************************/ +/** @name GNT Idle API */ +/**************************************************************************/ +/*@{*/ + +/** + * Returns the GNT idle UI ops. + * + * @return The UI operations structure. + */ +GaimIdleUiOps *gg_idle_get_ui_ops(void); + +/*@}*/ + +#endif /* _GG_IDLE_H_ */
--- a/console/libgnt/gntwm.c Mon Feb 26 16:29:05 2007 +0000 +++ b/console/libgnt/gntwm.c Tue Feb 27 04:11:46 2007 +0000 @@ -19,6 +19,8 @@ #include <stdlib.h> #include <string.h> +#define IDLE_CHECK_INTERVAL 5 /* 5 seconds */ + enum { SIG_NEW_WIN, @@ -45,6 +47,8 @@ static gboolean write_already(gpointer data); static int write_timeout; +static time_t last_active_time; +static gboolean idle_update; static GList * g_list_bring_to_front(GList *list, gpointer data) @@ -230,6 +234,15 @@ #endif } +static gboolean check_idle(gpointer n) +{ + if (idle_update) { + time(&last_active_time); + idle_update = FALSE; + } + return TRUE; +} + static void gnt_wm_init(GTypeInstance *instance, gpointer class) { @@ -243,6 +256,8 @@ wm->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE)) read_window_positions(wm); + g_timeout_add(IDLE_CHECK_INTERVAL * 1000, check_idle, NULL); + time(&last_active_time); } static void @@ -1089,10 +1104,17 @@ draw_taskbar(wm, FALSE); } +time_t gnt_wm_get_idle_time() +{ + return time(NULL) - last_active_time; +} + void gnt_wm_process_input(GntWM *wm, const char *keys) { keys = gnt_bindable_remap_keys(GNT_BINDABLE(wm), keys); + idle_update = TRUE; + if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) return; @@ -1344,6 +1366,7 @@ gboolean gnt_wm_process_click(GntWM *wm, GntMouseEvent event, int x, int y, GntWidget *widget) { + idle_update = TRUE; gboolean ret = TRUE; g_signal_emit(wm, signals[SIG_MOUSE_CLICK], 0, event, x, y, widget, &ret); return ret;