annotate pidgin/pidgintooltip.c @ 21904:9b299228431c

merge of '05319fdf1db00660d0c169657ed1b08ff621e5c7' and 'a654aa0d3c35e43c2f23b266100bfdb4d98e2d73'
author Will Thompson <will.thompson@collabora.co.uk>
date Wed, 19 Dec 2007 11:31:37 +0000
parents f5d961556972
children 2dafcbfc1556
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 /**
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 * @file pidgintooltip.c Pidgin Tooltip API
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 * @ingroup pidgin
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 */
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 /* pidgin
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 *
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 * Pidgin is the legal property of its developers, whose names are too numerous
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 * source distribution.
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 *
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 * (at your option) any later version.
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 *
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 * GNU General Public License for more details.
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 *
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 */
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 #include "internal.h"
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 #include "prefs.h"
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 #include "pidgin.h"
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 #include "pidgintooltip.h"
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
31 #include "debug.h"
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 struct
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 GtkWidget *widget;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 int timeout;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 GdkRectangle tip_rect;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 GtkWidget *tipwindow;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 PidginTooltipPaint paint_tooltip;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 } pidgin_tooltip;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 typedef struct
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 GtkWidget *widget;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 gpointer userdata;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 PidginTooltipCreateForTree create_tooltip;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 PidginTooltipPaint paint_tooltip;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 GtkTreePath *path;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 } PidginTooltipData;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 static void
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 destroy_tooltip_data(PidginTooltipData *data)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 gtk_tree_path_free(data->path);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 g_free(data);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58 void pidgin_tooltip_destroy()
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 if (pidgin_tooltip.timeout > 0) {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 g_source_remove(pidgin_tooltip.timeout);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 pidgin_tooltip.timeout = 0;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 if (pidgin_tooltip.tipwindow) {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65 gtk_widget_destroy(pidgin_tooltip.tipwindow);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 pidgin_tooltip.tipwindow = NULL;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
70 static gboolean
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 pidgin_tooltip_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 if (pidgin_tooltip.paint_tooltip)
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
74 pidgin_tooltip.paint_tooltip(widget, data);
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
75 return FALSE;
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
76 }
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
77
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
78 static GtkWidget*
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
79 setup_tooltip_window()
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
80 {
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
81 const char *name;
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
82 GtkWidget *tipwindow;
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
83
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
84 tipwindow = gtk_window_new(GTK_WINDOW_POPUP);
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
85 name = gtk_window_get_title(GTK_WINDOW(pidgin_tooltip.widget));
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
86 gtk_window_set_type_hint(GTK_WINDOW(tipwindow), GDK_WINDOW_TYPE_HINT_TOOLTIP);
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
87 gtk_widget_set_app_paintable(tipwindow, TRUE);
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
88 gtk_window_set_title(GTK_WINDOW(tipwindow), name ? name : _("Pidgin Tooltip"));
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
89 gtk_window_set_resizable(GTK_WINDOW(tipwindow), FALSE);
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
90 gtk_widget_set_name(tipwindow, "gtk-tooltips");
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
91 gtk_widget_ensure_style(tipwindow);
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
92 gtk_widget_realize(tipwindow);
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
93 return tipwindow;
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 static void
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
97 setup_tooltip_window_position(gpointer data, int w, int h)
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99 int sig;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 int scr_w, scr_h, x, y;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 #if GTK_CHECK_VERSION(2,2,0)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 int mon_num;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 GdkScreen *screen = NULL;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104 #endif
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 GdkRectangle mon_size;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 GtkWidget *tipwindow = pidgin_tooltip.tipwindow;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108 #if GTK_CHECK_VERSION(2,2,0)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109 gdk_display_get_pointer(gdk_display_get_default(), &screen, &x, &y, NULL);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 mon_num = gdk_screen_get_monitor_at_point(screen, x, y);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 gdk_screen_get_monitor_geometry(screen, mon_num, &mon_size);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 scr_w = mon_size.width + mon_size.x;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 scr_h = mon_size.height + mon_size.y;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 #else
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116 scr_w = gdk_screen_width();
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 scr_h = gdk_screen_height();
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 gdk_window_get_pointer(NULL, &x, &y, NULL);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 mon_size.x = 0;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 mon_size.y = 0;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 #endif
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 #if GTK_CHECK_VERSION(2,2,0)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 if (w > mon_size.width)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125 w = mon_size.width - 10;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 if (h > mon_size.height)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 h = mon_size.height - 10;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 #endif
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 x -= ((w >> 1) + 4);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 if ((y + h + 4) > scr_h)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
133 y = y - h - 5;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134 else
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 y = y + 6;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137 if (y < mon_size.y)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 y = mon_size.y;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140 if (y != mon_size.y) {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
141 if ((x + w) > scr_w)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142 x -= (x + w + 5) - scr_w;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 else if (x < mon_size.x)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 x = mon_size.x;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145 } else {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 x -= (w / 2 + 10);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 if (x < mon_size.x)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148 x = mon_size.x;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 gtk_widget_set_size_request(tipwindow, w, h);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 gtk_window_move(GTK_WINDOW(tipwindow), x, y);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 gtk_widget_show(tipwindow);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
155 g_signal_connect(G_OBJECT(tipwindow), "expose_event",
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
156 G_CALLBACK(pidgin_tooltip_expose_event), data);
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
157
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158 /* Hide the tooltip when the widget is destroyed */
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 sig = g_signal_connect(G_OBJECT(pidgin_tooltip.widget), "destroy", G_CALLBACK(pidgin_tooltip_destroy), NULL);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 g_signal_connect_swapped(G_OBJECT(tipwindow), "destroy", G_CALLBACK(g_source_remove), GINT_TO_POINTER(sig));
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 void pidgin_tooltip_show(GtkWidget *widget, gpointer userdata,
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 PidginTooltipCreate create_tooltip, PidginTooltipPaint paint_tooltip)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 GtkWidget *tipwindow;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 int w, h;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 pidgin_tooltip_destroy();
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
170
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 pidgin_tooltip.widget = gtk_widget_get_toplevel(widget);
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
172 pidgin_tooltip.tipwindow = tipwindow = setup_tooltip_window();
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 pidgin_tooltip.paint_tooltip = paint_tooltip;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 if (!create_tooltip(tipwindow, userdata, &w, &h)) {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 pidgin_tooltip_destroy();
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 return;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 }
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
179 setup_tooltip_window_position(userdata, w, h);
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 static void
21884
b40a6bb267a1 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21881
diff changeset
183 reset_data_treepath(PidginTooltipData *data)
b40a6bb267a1 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21881
diff changeset
184 {
b40a6bb267a1 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21881
diff changeset
185 gtk_tree_path_free(data->path);
b40a6bb267a1 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21881
diff changeset
186 data->path = NULL;
b40a6bb267a1 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21881
diff changeset
187 }
b40a6bb267a1 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21881
diff changeset
188
b40a6bb267a1 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21881
diff changeset
189 static void
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 pidgin_tooltip_draw(PidginTooltipData *data)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 GtkWidget *tipwindow;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 GtkTreePath *path = NULL;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194 int w, h;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(data->widget),
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 pidgin_tooltip.tip_rect.x,
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 pidgin_tooltip.tip_rect.y + (pidgin_tooltip.tip_rect.height/2),
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199 &path, NULL, NULL, NULL)) {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200 pidgin_tooltip_destroy();
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 return;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 if (data->path) {
21881
a69a4307c9a8 Plug a leak. And a patch from 'js' to fix tooltips in compiz fusion. References #4323.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21880
diff changeset
205 if (gtk_tree_path_compare(data->path, path) == 0) {
a69a4307c9a8 Plug a leak. And a patch from 'js' to fix tooltips in compiz fusion. References #4323.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21880
diff changeset
206 gtk_tree_path_free(path);
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 return;
21881
a69a4307c9a8 Plug a leak. And a patch from 'js' to fix tooltips in compiz fusion. References #4323.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21880
diff changeset
208 }
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 gtk_tree_path_free(data->path);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 data->path = NULL;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212
21880
b93c099dcfe4 Make sure an old tooltip is destroyed before creating a new one.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21877
diff changeset
213 pidgin_tooltip_destroy();
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
214
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215 pidgin_tooltip.widget = gtk_widget_get_toplevel(data->widget);
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
216 pidgin_tooltip.tipwindow = tipwindow = setup_tooltip_window();
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 pidgin_tooltip.paint_tooltip = data->paint_tooltip;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 if (!data->create_tooltip(tipwindow, path, data->userdata, &w, &h)) {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 pidgin_tooltip_destroy();
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 gtk_tree_path_free(path);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 return;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
225 setup_tooltip_window_position(data->userdata, w, h);
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
226
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 data->path = path;
21884
b40a6bb267a1 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21881
diff changeset
228 g_signal_connect_swapped(G_OBJECT(tipwindow), "destroy",
b40a6bb267a1 Reset tree-path when a tooltip is destroyed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21881
diff changeset
229 G_CALLBACK(reset_data_treepath), data);
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232 static gboolean
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 pidgin_tooltip_timeout(gpointer data)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
234 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 pidgin_tooltip.timeout = 0;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 pidgin_tooltip_draw(data);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 return FALSE;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 static gboolean
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241 row_motion_cb(GtkWidget *tv, GdkEventMotion *event, gpointer userdata)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243 GtkTreePath *path;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 int delay;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
246 if (event->window != gtk_tree_view_get_bin_window(GTK_TREE_VIEW(tv)))
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
247 return FALSE; /* The cursor is probably on the TreeView's header. */
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
248
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249 /* XXX: probably use something more generic? */
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 delay = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/tooltip_delay");
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251 if (delay == 0)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 return FALSE;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 if (pidgin_tooltip.timeout) {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255 if ((event->y >= pidgin_tooltip.tip_rect.y) && ((event->y - pidgin_tooltip.tip_rect.height) <= pidgin_tooltip.tip_rect.y))
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256 return FALSE;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257 /* We've left the cell. Remove the timeout and create a new one below */
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 pidgin_tooltip_destroy();
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
259 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
261 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263 if (path == NULL) {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264 pidgin_tooltip_destroy();
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
265 return FALSE;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
266 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
268 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &pidgin_tooltip.tip_rect);
21885
f5d961556972 Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21884
diff changeset
269 gtk_tree_path_free(path);
21877
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
271 pidgin_tooltip.timeout = g_timeout_add(delay, (GSourceFunc)pidgin_tooltip_timeout, userdata);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273 return FALSE;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
276 static gboolean
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
277 row_leave_cb(GtkWidget *tv, GdkEvent *event, gpointer userdata)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
279 pidgin_tooltip_destroy();
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
280 return FALSE;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
281 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
282
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
283 gboolean pidgin_tooltip_setup_for_treeview(GtkWidget *tree, gpointer userdata,
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
284 PidginTooltipCreateForTree create_tooltip, PidginTooltipPaint paint_tooltip)
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
285 {
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
286 PidginTooltipData *tdata = g_new0(PidginTooltipData, 1);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
287 tdata->widget = tree;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
288 tdata->userdata = userdata;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289 tdata->create_tooltip = create_tooltip;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
290 tdata->paint_tooltip = paint_tooltip;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
291
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
292 g_signal_connect(G_OBJECT(tree), "motion-notify-event", G_CALLBACK(row_motion_cb), tdata);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
293 g_signal_connect(G_OBJECT(tree), "leave-notify-event", G_CALLBACK(row_leave_cb), NULL);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
294 g_signal_connect_swapped(G_OBJECT(tree), "destroy", G_CALLBACK(destroy_tooltip_data), tdata);
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
295 return TRUE;
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
296 }
6bf73aea6450 Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
297