pidgin/pidgintooltip.c

Wed, 23 Jul 2008 03:30:07 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Wed, 23 Jul 2008 03:30:07 +0000
changeset 23901
fb9610ea214c
parent 22104
56970903b8e9
child 24558
7d4379a9536e
permissions
-rw-r--r--

Jan Kratochvil noticed there was a race condition in the treeview tooltip
code, this fixes it. Fixes #6229.

21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
1 /**
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
2 * @file pidgintooltip.c Pidgin Tooltip API
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
3 * @ingroup pidgin
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
4 */
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
5
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
6 /* pidgin
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
7 *
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
8 * Pidgin is the legal property of its developers, whose names are too numerous
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
10 * source distribution.
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
11 *
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
15 * (at your option) any later version.
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
16 *
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
20 * GNU General Public License for more details.
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
21 *
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
25 */
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
26
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
27 #include "internal.h"
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
28 #include "prefs.h"
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
29 #include "pidgin.h"
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
30 #include "pidgintooltip.h"
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
31 #include "debug.h"
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
32
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
33 struct
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
34 {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
35 GtkWidget *widget;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
36 int timeout;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
37 GdkRectangle tip_rect;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
38 GtkWidget *tipwindow;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
39 PidginTooltipPaint paint_tooltip;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
40 } pidgin_tooltip;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
41
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
42 typedef struct
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
43 {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
44 GtkWidget *widget;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
45 gpointer userdata;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
46 PidginTooltipPaint paint_tooltip;
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
47 union {
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
48 struct {
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
49 PidginTooltipCreateForTree create_tooltip;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
50 GtkTreePath *path;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
51 } treeview;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
52 struct {
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
53 PidginTooltipCreate create_tooltip;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
54 } widget;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
55 } common;
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
56 } PidginTooltipData;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
57
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
58 static void
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
59 destroy_tooltip_data(PidginTooltipData *data)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
60 {
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
61 gtk_tree_path_free(data->common.treeview.path);
23901
fb9610ea214c Jan Kratochvil noticed there was a race condition in the treeview tooltip
Daniel Atallah <datallah@pidgin.im>
parents: 22104
diff changeset
62 pidgin_tooltip_destroy();
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
63 g_free(data);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
64 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
65
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
66 void pidgin_tooltip_destroy()
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
67 {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
68 if (pidgin_tooltip.timeout > 0) {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
69 g_source_remove(pidgin_tooltip.timeout);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
70 pidgin_tooltip.timeout = 0;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
71 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
72 if (pidgin_tooltip.tipwindow) {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
73 gtk_widget_destroy(pidgin_tooltip.tipwindow);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
74 pidgin_tooltip.tipwindow = NULL;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
75 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
76 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
77
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
78 static gboolean
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
79 pidgin_tooltip_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
80 {
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
81 if (pidgin_tooltip.paint_tooltip) {
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
82 gtk_paint_flat_box(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
83 NULL, widget, "tooltip", 0, 0, -1, -1);
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
84 pidgin_tooltip.paint_tooltip(widget, data);
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
85 }
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
86 return FALSE;
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
87 }
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
88
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
89 static GtkWidget*
22104
56970903b8e9 Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents: 22064
diff changeset
90 setup_tooltip_window(void)
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
91 {
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
92 const char *name;
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
93 GtkWidget *tipwindow;
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
94
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
95 tipwindow = gtk_window_new(GTK_WINDOW_POPUP);
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
96 name = gtk_window_get_title(GTK_WINDOW(pidgin_tooltip.widget));
22022
0e7195deb9f8 GDK_WINDOW_TYPE_HINT_TOOLTIP is GTK+ >= 2.10.0
Daniel Atallah <datallah@pidgin.im>
parents: 21998
diff changeset
97 #if GTK_CHECK_VERSION(2,10,0)
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
98 gtk_window_set_type_hint(GTK_WINDOW(tipwindow), GDK_WINDOW_TYPE_HINT_TOOLTIP);
22022
0e7195deb9f8 GDK_WINDOW_TYPE_HINT_TOOLTIP is GTK+ >= 2.10.0
Daniel Atallah <datallah@pidgin.im>
parents: 21998
diff changeset
99 #endif
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
100 gtk_widget_set_app_paintable(tipwindow, TRUE);
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
101 gtk_window_set_title(GTK_WINDOW(tipwindow), name ? name : _("Pidgin Tooltip"));
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
102 gtk_window_set_resizable(GTK_WINDOW(tipwindow), FALSE);
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
103 gtk_widget_set_name(tipwindow, "gtk-tooltips");
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
104 gtk_widget_ensure_style(tipwindow);
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
105 gtk_widget_realize(tipwindow);
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
106 return tipwindow;
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
107 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
108
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
109 static void
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
110 setup_tooltip_window_position(gpointer data, int w, int h)
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
111 {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
112 int sig;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
113 int scr_w, scr_h, x, y;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
114 #if GTK_CHECK_VERSION(2,2,0)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
115 int mon_num;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
116 GdkScreen *screen = NULL;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
117 #endif
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
118 GdkRectangle mon_size;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
119 GtkWidget *tipwindow = pidgin_tooltip.tipwindow;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
120
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
121 #if GTK_CHECK_VERSION(2,2,0)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
122 gdk_display_get_pointer(gdk_display_get_default(), &screen, &x, &y, NULL);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
123 mon_num = gdk_screen_get_monitor_at_point(screen, x, y);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
124 gdk_screen_get_monitor_geometry(screen, mon_num, &mon_size);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
125
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
126 scr_w = mon_size.width + mon_size.x;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
127 scr_h = mon_size.height + mon_size.y;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
128 #else
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
129 scr_w = gdk_screen_width();
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
130 scr_h = gdk_screen_height();
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
131 gdk_window_get_pointer(NULL, &x, &y, NULL);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
132 mon_size.x = 0;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
133 mon_size.y = 0;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
134 #endif
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
135
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
136 #if GTK_CHECK_VERSION(2,2,0)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
137 if (w > mon_size.width)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
138 w = mon_size.width - 10;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
139
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
140 if (h > mon_size.height)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
141 h = mon_size.height - 10;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
142 #endif
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
143 x -= ((w >> 1) + 4);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
144
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
145 if ((y + h + 4) > scr_h)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
146 y = y - h - 5;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
147 else
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
148 y = y + 6;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
149
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
150 if (y < mon_size.y)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
151 y = mon_size.y;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
152
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
153 if (y != mon_size.y) {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
154 if ((x + w) > scr_w)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
155 x -= (x + w + 5) - scr_w;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
156 else if (x < mon_size.x)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
157 x = mon_size.x;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
158 } else {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
159 x -= (w / 2 + 10);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
160 if (x < mon_size.x)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
161 x = mon_size.x;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
162 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
163
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
164 gtk_widget_set_size_request(tipwindow, w, h);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
165 gtk_window_move(GTK_WINDOW(tipwindow), x, y);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
166 gtk_widget_show(tipwindow);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
167
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
168 g_signal_connect(G_OBJECT(tipwindow), "expose_event",
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
169 G_CALLBACK(pidgin_tooltip_expose_event), data);
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
170
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
171 /* Hide the tooltip when the widget is destroyed */
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
172 sig = g_signal_connect(G_OBJECT(pidgin_tooltip.widget), "destroy", G_CALLBACK(pidgin_tooltip_destroy), NULL);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
173 g_signal_connect_swapped(G_OBJECT(tipwindow), "destroy", G_CALLBACK(g_source_remove), GINT_TO_POINTER(sig));
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
174 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
175
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
176 void pidgin_tooltip_show(GtkWidget *widget, gpointer userdata,
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
177 PidginTooltipCreate create_tooltip, PidginTooltipPaint paint_tooltip)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
178 {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
179 GtkWidget *tipwindow;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
180 int w, h;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
181
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
182 pidgin_tooltip_destroy();
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
183
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
184 pidgin_tooltip.widget = gtk_widget_get_toplevel(widget);
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
185 pidgin_tooltip.tipwindow = tipwindow = setup_tooltip_window();
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
186 pidgin_tooltip.paint_tooltip = paint_tooltip;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
187
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
188 if (!create_tooltip(tipwindow, userdata, &w, &h)) {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
189 pidgin_tooltip_destroy();
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
190 return;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
191 }
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
192 setup_tooltip_window_position(userdata, w, h);
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
193 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
194
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
195 static void
21997
08bc3d1daa99 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21994
diff changeset
196 reset_data_treepath(PidginTooltipData *data)
08bc3d1daa99 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21994
diff changeset
197 {
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
198 gtk_tree_path_free(data->common.treeview.path);
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
199 data->common.treeview.path = NULL;
21997
08bc3d1daa99 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21994
diff changeset
200 }
08bc3d1daa99 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21994
diff changeset
201
08bc3d1daa99 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21994
diff changeset
202 static void
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
203 pidgin_tooltip_draw(PidginTooltipData *data)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
204 {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
205 GtkWidget *tipwindow;
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
206 int w, h;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
207
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
208 pidgin_tooltip_destroy();
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
209
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
210 pidgin_tooltip.widget = gtk_widget_get_toplevel(data->widget);
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
211 pidgin_tooltip.tipwindow = tipwindow = setup_tooltip_window();
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
212 pidgin_tooltip.paint_tooltip = data->paint_tooltip;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
213
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
214 if (!data->common.widget.create_tooltip(tipwindow, data->userdata, &w, &h)) {
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
215 if (tipwindow == pidgin_tooltip.tipwindow)
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
216 pidgin_tooltip_destroy();
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
217 return;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
218 }
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
219
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
220 setup_tooltip_window_position(data->userdata, w, h);
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
221 }
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
222
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
223 static void
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
224 pidgin_tooltip_draw_tree(PidginTooltipData *data)
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
225 {
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
226 GtkWidget *tipwindow;
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
227 GtkTreePath *path = NULL;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
228 int w, h;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
229
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
230 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(data->widget),
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
231 pidgin_tooltip.tip_rect.x,
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
232 pidgin_tooltip.tip_rect.y + (pidgin_tooltip.tip_rect.height/2),
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
233 &path, NULL, NULL, NULL)) {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
234 pidgin_tooltip_destroy();
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
235 return;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
236 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
237
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
238 if (data->common.treeview.path) {
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
239 if (gtk_tree_path_compare(data->common.treeview.path, path) == 0) {
21994
6ff974b162c0 Plug a leak. And a patch from 'js' to fix tooltips in compiz fusion. References #4323.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21993
diff changeset
240 gtk_tree_path_free(path);
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
241 return;
21994
6ff974b162c0 Plug a leak. And a patch from 'js' to fix tooltips in compiz fusion. References #4323.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21993
diff changeset
242 }
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
243 gtk_tree_path_free(data->common.treeview.path);
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
244 data->common.treeview.path = NULL;
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
245 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
246
21993
3fdb200f15bb Make sure an old tooltip is destroyed before creating a new one.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21903
diff changeset
247 pidgin_tooltip_destroy();
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
248
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
249 pidgin_tooltip.widget = gtk_widget_get_toplevel(data->widget);
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
250 pidgin_tooltip.tipwindow = tipwindow = setup_tooltip_window();
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
251 pidgin_tooltip.paint_tooltip = data->paint_tooltip;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
252
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
253 if (!data->common.treeview.create_tooltip(tipwindow, path, data->userdata, &w, &h)) {
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
254 if (tipwindow == pidgin_tooltip.tipwindow)
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
255 pidgin_tooltip_destroy();
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
256 gtk_tree_path_free(path);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
257 return;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
258 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
259
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
260 setup_tooltip_window_position(data->userdata, w, h);
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
261
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
262 data->common.treeview.path = path;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
263 g_signal_connect_swapped(G_OBJECT(pidgin_tooltip.tipwindow), "destroy",
21997
08bc3d1daa99 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21994
diff changeset
264 G_CALLBACK(reset_data_treepath), data);
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
265 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
266
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
267 static gboolean
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
268 pidgin_tooltip_timeout(gpointer data)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
269 {
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
270 PidginTooltipData *tdata = data;
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
271 pidgin_tooltip.timeout = 0;
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
272 if (GTK_IS_TREE_VIEW(tdata->widget))
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
273 pidgin_tooltip_draw_tree(data);
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
274 else
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
275 pidgin_tooltip_draw(data);
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
276 return FALSE;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
277 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
278
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
279 static gboolean
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
280 row_motion_cb(GtkWidget *tv, GdkEventMotion *event, gpointer userdata)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
281 {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
282 GtkTreePath *path;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
283 int delay;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
284
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
285 if (event->window != gtk_tree_view_get_bin_window(GTK_TREE_VIEW(tv)))
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
286 return FALSE; /* The cursor is probably on the TreeView's header. */
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
287
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
288 /* XXX: probably use something more generic? */
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
289 delay = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/tooltip_delay");
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
290 if (delay == 0)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
291 return FALSE;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
292
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
293 if (pidgin_tooltip.timeout) {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
294 if ((event->y >= pidgin_tooltip.tip_rect.y) && ((event->y - pidgin_tooltip.tip_rect.height) <= pidgin_tooltip.tip_rect.y))
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
295 return FALSE;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
296 /* We've left the cell. Remove the timeout and create a new one below */
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
297 pidgin_tooltip_destroy();
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
298 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
299
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
300 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
301
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
302 if (path == NULL) {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
303 pidgin_tooltip_destroy();
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
304 return FALSE;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
305 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
306
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
307 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &pidgin_tooltip.tip_rect);
21998
3dbae318c88d Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21997
diff changeset
308 gtk_tree_path_free(path);
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
309
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
310 pidgin_tooltip.timeout = g_timeout_add(delay, (GSourceFunc)pidgin_tooltip_timeout, userdata);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
311
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
312 return FALSE;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
313 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
314
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
315 static gboolean
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
316 widget_leave_cb(GtkWidget *tv, GdkEvent *event, gpointer userdata)
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
317 {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
318 pidgin_tooltip_destroy();
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
319 return FALSE;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
320 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
321
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
322 gboolean pidgin_tooltip_setup_for_treeview(GtkWidget *tree, gpointer userdata,
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
323 PidginTooltipCreateForTree create_tooltip, PidginTooltipPaint paint_tooltip)
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
324 {
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
325 PidginTooltipData *tdata = g_new0(PidginTooltipData, 1);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
326 tdata->widget = tree;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
327 tdata->userdata = userdata;
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
328 tdata->common.treeview.create_tooltip = create_tooltip;
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
329 tdata->paint_tooltip = paint_tooltip;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
330
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
331 g_signal_connect(G_OBJECT(tree), "motion-notify-event", G_CALLBACK(row_motion_cb), tdata);
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
332 g_signal_connect(G_OBJECT(tree), "leave-notify-event", G_CALLBACK(widget_leave_cb), NULL);
21903
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
333 g_signal_connect_swapped(G_OBJECT(tree), "destroy", G_CALLBACK(destroy_tooltip_data), tdata);
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
334 return TRUE;
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
335 }
5b5ad54ae1da Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
336
22064
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
337 static gboolean
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
338 widget_motion_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
339 {
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
340 int delay = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/tooltip_delay");
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
341
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
342 pidgin_tooltip_destroy();
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
343 if (delay == 0)
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
344 return FALSE;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
345
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
346 pidgin_tooltip.timeout = g_timeout_add(delay, (GSourceFunc)pidgin_tooltip_timeout, data);
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
347 return FALSE;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
348 }
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
349
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
350 gboolean pidgin_tooltip_setup_for_widget(GtkWidget *widget, gpointer userdata,
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
351 PidginTooltipCreate create_tooltip, PidginTooltipPaint paint_tooltip)
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
352 {
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
353 PidginTooltipData *wdata = g_new0(PidginTooltipData, 1);
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
354 wdata->widget = widget;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
355 wdata->userdata = userdata;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
356 wdata->common.widget.create_tooltip = create_tooltip;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
357 wdata->paint_tooltip = paint_tooltip;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
358
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
359 g_signal_connect(G_OBJECT(widget), "motion-notify-event", G_CALLBACK(widget_motion_cb), wdata);
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
360 g_signal_connect(G_OBJECT(widget), "leave-notify-event", G_CALLBACK(widget_leave_cb), NULL);
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
361 g_signal_connect_swapped(G_OBJECT(widget), "destroy", G_CALLBACK(g_free), wdata);
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
362 return TRUE;
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
363 }
8b35fd51087d Use the new tooltip functions to draw the tooltips in the conversation window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22022
diff changeset
364

mercurial