Thu, 08 Jan 2009 05:00:02 +0000
Use "Add Buddy Pounce" and "Modify Buddy Pounce" as the buddy pounce dialog
titles instead of "New Buddy Pounce" and "Edit Buddy Pounce" to match the "Add
Account" and "Modify Account" dialogs.
I went this way figuring more people are likely to have seen the account
dialogs than the buddy pounce dialogs, but if we like New/Edit better than
Add/Modify we can switch the other way.
| 10298 | 1 | /* |
| 2 | * @file gtkdnd-hints.c GTK+ Drag-and-Drop arrow hints | |
|
16254
eeb2bba4dc94
Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@pidgin.im>
parents:
15946
diff
changeset
|
3 | * @ingroup pidgin |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* pidgin |
| 10298 | 7 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
8 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 10298 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 11 | * | |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2, or(at your option) | |
| 15 | * any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17176
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA. |
| 10298 | 25 | */ |
| 26 | ||
| 27 | #include "gtkdnd-hints.h" | |
| 28 | ||
| 29 | #include <gtk/gtk.h> | |
| 30 | #include <gdk/gdk.h> | |
| 31 | #include <gdk-pixbuf/gdk-pixbuf.h> | |
| 32 | ||
| 33 | #ifdef _WIN32 | |
| 34 | #include "win32dep.h" | |
| 35 | #endif | |
| 36 | ||
| 37 | typedef struct | |
| 38 | { | |
| 39 | GtkWidget *widget; | |
| 40 | gchar *filename; | |
| 41 | gint ox; | |
| 42 | gint oy; | |
| 43 | ||
| 44 | } HintWindowInfo; | |
| 45 | ||
| 46 | /** | |
| 47 | * Info about each hint widget. See DndHintWindowId enum. | |
| 48 | */ | |
|
10871
c0282a4f2250
[gaim-migrate @ 12558]
Mark Doliner <markdoliner@pidgin.im>
parents:
10298
diff
changeset
|
49 | static HintWindowInfo hint_windows[] = { |
|
16274
7d61ad2c489a
Some icon improvements from hbons
Sean Egan <seanegan@pidgin.im>
parents:
16254
diff
changeset
|
50 | { NULL, "arrow-up.xpm", -13/2, 0 }, |
|
7d61ad2c489a
Some icon improvements from hbons
Sean Egan <seanegan@pidgin.im>
parents:
16254
diff
changeset
|
51 | { NULL, "arrow-down.xpm", -13/2, -16 }, |
|
7d61ad2c489a
Some icon improvements from hbons
Sean Egan <seanegan@pidgin.im>
parents:
16254
diff
changeset
|
52 | { NULL, "arrow-left.xpm", 0, -13/2 }, |
|
7d61ad2c489a
Some icon improvements from hbons
Sean Egan <seanegan@pidgin.im>
parents:
16254
diff
changeset
|
53 | { NULL, "arrow-right.xpm", -16, -13/2 }, |
| 10298 | 54 | { NULL, NULL, 0, 0 } |
| 55 | }; | |
| 56 | ||
| 57 | static GtkWidget * | |
| 58 | dnd_hints_init_window(const gchar *fname) | |
| 59 | { | |
| 60 | GdkPixbuf *pixbuf; | |
| 61 | GdkPixmap *pixmap; | |
| 62 | GdkBitmap *bitmap; | |
| 63 | GtkWidget *pix; | |
| 64 | GtkWidget *win; | |
| 65 | ||
| 66 | pixbuf = gdk_pixbuf_new_from_file(fname, NULL); | |
| 67 | g_return_val_if_fail(pixbuf, NULL); | |
| 68 | ||
| 69 | gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &bitmap, 128); | |
| 70 | g_object_unref(G_OBJECT(pixbuf)); | |
| 71 | ||
| 72 | gtk_widget_push_colormap(gdk_rgb_get_colormap()); | |
| 73 | win = gtk_window_new(GTK_WINDOW_POPUP); | |
| 74 | pix = gtk_image_new_from_pixmap(pixmap, bitmap); | |
| 75 | gtk_container_add(GTK_CONTAINER(win), pix); | |
| 76 | gtk_widget_shape_combine_mask(win, bitmap, 0, 0); | |
| 77 | gtk_widget_pop_colormap(); | |
| 78 | ||
| 79 | g_object_unref(G_OBJECT(pixmap)); | |
| 80 | g_object_unref(G_OBJECT(bitmap)); | |
| 81 | ||
| 82 | gtk_widget_show_all(pix); | |
| 83 | ||
| 84 | return win; | |
| 85 | } | |
| 86 | ||
| 87 | static void | |
| 88 | get_widget_coords(GtkWidget *w, gint *x1, gint *y1, gint *x2, gint *y2) | |
| 89 | { | |
| 90 | gint ox, oy, width, height; | |
| 91 | ||
| 92 | if (w->parent && w->parent->window == w->window) | |
| 93 | { | |
| 94 | get_widget_coords(w->parent, &ox, &oy, NULL, NULL); | |
| 95 | height = w->allocation.height; | |
| 96 | width = w->allocation.width; | |
| 97 | } | |
| 98 | else | |
| 99 | { | |
| 100 | gdk_window_get_origin(w->window, &ox, &oy); | |
| 101 | gdk_drawable_get_size(w->window, &width, &height); | |
| 102 | } | |
| 103 | ||
| 104 | if (x1) *x1 = ox; | |
| 105 | if (y1) *y1 = oy; | |
| 106 | if (x2) *x2 = ox + width; | |
| 107 | if (y2) *y2 = oy + height; | |
| 108 | } | |
| 109 | ||
| 110 | static void | |
| 111 | dnd_hints_init(void) | |
| 112 | { | |
| 113 | static gboolean done = FALSE; | |
| 114 | gint i; | |
| 115 | ||
| 116 | if (done) | |
| 117 | return; | |
| 118 | ||
| 119 | done = TRUE; | |
| 120 | ||
| 121 | for (i = 0; hint_windows[i].filename != NULL; i++) { | |
| 122 | gchar *fname; | |
| 123 | ||
|
15946
d40e8847e825
More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
124 | fname = g_build_filename(DATADIR, "pixmaps", "pidgin", |
| 10298 | 125 | hint_windows[i].filename, NULL); |
| 126 | ||
| 127 | hint_windows[i].widget = dnd_hints_init_window(fname); | |
| 128 | ||
| 129 | g_free(fname); | |
| 130 | } | |
| 131 | } | |
| 132 | ||
| 133 | void | |
| 134 | dnd_hints_hide_all(void) | |
| 135 | { | |
| 136 | gint i; | |
| 137 | ||
| 138 | for (i = 0; hint_windows[i].filename != NULL; i++) | |
| 139 | dnd_hints_hide(i); | |
| 140 | } | |
| 141 | ||
| 142 | void | |
| 143 | dnd_hints_hide(DndHintWindowId i) | |
| 144 | { | |
| 145 | GtkWidget *w = hint_windows[i].widget; | |
| 146 | ||
| 147 | if (w && GTK_IS_WIDGET(w)) | |
| 148 | gtk_widget_hide(w); | |
| 149 | } | |
| 150 | ||
| 151 | void | |
| 152 | dnd_hints_show(DndHintWindowId id, gint x, gint y) | |
| 153 | { | |
| 154 | GtkWidget *w; | |
| 155 | ||
| 156 | dnd_hints_init(); | |
| 157 | ||
| 158 | w = hint_windows[id].widget; | |
| 159 | ||
| 160 | if (w && GTK_IS_WIDGET(w)) | |
| 161 | { | |
| 162 | gtk_window_move(GTK_WINDOW(w), hint_windows[id].ox + x, | |
| 163 | hint_windows[id].oy + y); | |
| 164 | gtk_widget_show(w); | |
| 165 | } | |
| 166 | } | |
| 167 | ||
| 168 | void | |
| 169 | dnd_hints_show_relative(DndHintWindowId id, GtkWidget *widget, | |
| 170 | DndHintPosition horiz, DndHintPosition vert) | |
| 171 | { | |
| 172 | gint x1, x2, y1, y2; | |
| 173 | gint x = 0, y = 0; | |
| 174 | ||
| 175 | get_widget_coords(widget, &x1, &y1, &x2, &y2); | |
|
17176
39ea409eb27d
Fix background color issues in the coversation tabs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16274
diff
changeset
|
176 | x1 += widget->allocation.x; x2 += widget->allocation.x; |
|
39ea409eb27d
Fix background color issues in the coversation tabs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16274
diff
changeset
|
177 | y1 += widget->allocation.y; y2 += widget->allocation.y; |
| 10298 | 178 | |
| 179 | switch (horiz) | |
| 180 | { | |
| 181 | case HINT_POSITION_RIGHT: x = x2; break; | |
| 182 | case HINT_POSITION_LEFT: x = x1; break; | |
| 183 | case HINT_POSITION_CENTER: x = (x1 + x2) / 2; break; | |
| 184 | default: | |
| 185 | /* should not happen */ | |
| 186 | g_warning("Invalid parameter to dnd_hints_show_relative"); | |
| 187 | break; | |
| 188 | } | |
| 189 | ||
| 190 | switch (vert) | |
| 191 | { | |
| 192 | case HINT_POSITION_TOP: y = y1; break; | |
| 193 | case HINT_POSITION_BOTTOM: y = y2; break; | |
| 194 | case HINT_POSITION_CENTER: y = (y1 + y2) / 2; break; | |
| 195 | default: | |
| 196 | /* should not happen */ | |
| 197 | g_warning("Invalid parameter to dnd_hints_show_relative"); | |
| 198 | break; | |
| 199 | } | |
| 200 | ||
| 201 | dnd_hints_show(id, x, y); | |
| 202 | } | |
| 203 |