Tue, 17 Oct 2006 08:13:41 +0000
[gaim-migrate @ 17495]
This should fix the statusbox issues that were keeping us from releasing beta
4 (and which were just really annoying). Thakn sadrul for most of this, I just
added the if (index == -1) bit. Anyway, the way this works now is that for
saved/popular statuses the primitive underlying that status is where the
dropdown for the statusbox starts. If we don't like that we can change it but
I'm not sure we'll find something better.
Also, this might plug a couple leaks, I'm not really sure but it certainly
looks right.
Up next, the patch to make the docklet use the per-protocol statuses in the
top section.
| 8273 | 1 | /** |
| 2 | * @file gtk_eventloop.c Gaim Event Loop API (gtk implementation) | |
| 3 | * @ingroup gtkui | |
| 4 | * | |
| 5 | * gaim | |
| 6 | * | |
| 7 | * Gaim is the legal property of its developers, whose names are too numerous | |
| 8 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 9 | * source distribution. | |
| 10 | * | |
| 11 | * This program is free software; you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 | */ | |
| 25 | ||
| 26 | #include <glib.h> | |
| 27 | #include "gtkeventloop.h" | |
| 28 | #include "eventloop.h" | |
|
14793
66e32c262451
[gaim-migrate @ 17487]
Daniel Atallah <datallah@pidgin.im>
parents:
14792
diff
changeset
|
29 | #ifdef _WIN32 |
|
14792
02a5df4343f7
[gaim-migrate @ 17486]
Daniel Atallah <datallah@pidgin.im>
parents:
14253
diff
changeset
|
30 | #include "win32dep.h" |
|
14793
66e32c262451
[gaim-migrate @ 17487]
Daniel Atallah <datallah@pidgin.im>
parents:
14792
diff
changeset
|
31 | #endif |
| 8273 | 32 | |
| 33 | #define GAIM_GTK_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) | |
| 34 | #define GAIM_GTK_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) | |
| 35 | ||
| 36 | typedef struct _GaimGtkIOClosure { | |
| 37 | GaimInputFunction function; | |
| 38 | guint result; | |
| 39 | gpointer data; | |
| 40 | ||
| 41 | } GaimGtkIOClosure; | |
| 42 | ||
| 43 | static void gaim_gtk_io_destroy(gpointer data) | |
| 44 | { | |
| 45 | g_free(data); | |
| 46 | } | |
| 47 | ||
| 48 | static gboolean gaim_gtk_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) | |
| 49 | { | |
| 50 | GaimGtkIOClosure *closure = data; | |
| 51 | GaimInputCondition gaim_cond = 0; | |
| 52 | ||
| 53 | if (condition & GAIM_GTK_READ_COND) | |
| 54 | gaim_cond |= GAIM_INPUT_READ; | |
| 55 | if (condition & GAIM_GTK_WRITE_COND) | |
| 56 | gaim_cond |= GAIM_INPUT_WRITE; | |
| 57 | ||
| 58 | #if 0 | |
| 59 | gaim_debug(GAIM_DEBUG_MISC, "gtk_eventloop", | |
| 60 | "CLOSURE: callback for %d, fd is %d\n", | |
| 61 | closure->result, g_io_channel_unix_get_fd(source)); | |
| 62 | #endif | |
| 63 | ||
|
11065
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
64 | #ifdef _WIN32 |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
65 | if(! gaim_cond) { |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
66 | #if DEBUG |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
67 | gaim_debug(GAIM_DEBUG_MISC, "gtk_eventloop", |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
68 | "CLOSURE received GIOCondition of 0x%x, which does not" |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
69 | " match 0x%x (READ) or 0x%x (WRITE)\n", |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
70 | condition, GAIM_GTK_READ_COND, GAIM_GTK_WRITE_COND); |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
71 | #endif /* DEBUG */ |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
72 | |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
73 | return TRUE; |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
74 | } |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
75 | #endif /* _WIN32 */ |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
76 | |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
77 | closure->function(closure->data, g_io_channel_unix_get_fd(source), |
|
895342350443
[gaim-migrate @ 13046]
Christopher O'Brien <siege@pidgin.im>
parents:
8807
diff
changeset
|
78 | gaim_cond); |
| 8273 | 79 | |
| 80 | return TRUE; | |
| 81 | } | |
| 82 | ||
| 8280 | 83 | static guint gaim_gtk_input_add(gint fd, GaimInputCondition condition, GaimInputFunction function, |
| 8273 | 84 | gpointer data) |
| 85 | { | |
| 86 | GaimGtkIOClosure *closure = g_new0(GaimGtkIOClosure, 1); | |
| 87 | GIOChannel *channel; | |
| 88 | GIOCondition cond = 0; | |
| 89 | ||
| 90 | closure->function = function; | |
| 91 | closure->data = data; | |
| 92 | ||
| 93 | if (condition & GAIM_INPUT_READ) | |
| 94 | cond |= GAIM_GTK_READ_COND; | |
| 95 | if (condition & GAIM_INPUT_WRITE) | |
| 96 | cond |= GAIM_GTK_WRITE_COND; | |
| 97 | ||
|
14792
02a5df4343f7
[gaim-migrate @ 17486]
Daniel Atallah <datallah@pidgin.im>
parents:
14253
diff
changeset
|
98 | #ifdef _WIN32 |
|
02a5df4343f7
[gaim-migrate @ 17486]
Daniel Atallah <datallah@pidgin.im>
parents:
14253
diff
changeset
|
99 | channel = wgaim_g_io_channel_win32_new_socket(fd); |
|
02a5df4343f7
[gaim-migrate @ 17486]
Daniel Atallah <datallah@pidgin.im>
parents:
14253
diff
changeset
|
100 | #else |
| 8280 | 101 | channel = g_io_channel_unix_new(fd); |
|
14792
02a5df4343f7
[gaim-migrate @ 17486]
Daniel Atallah <datallah@pidgin.im>
parents:
14253
diff
changeset
|
102 | #endif |
| 8273 | 103 | closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, |
| 104 | gaim_gtk_io_invoke, closure, gaim_gtk_io_destroy); | |
| 105 | ||
| 106 | #if 0 | |
| 107 | gaim_debug(GAIM_DEBUG_MISC, "gtk_eventloop", | |
| 108 | "CLOSURE: adding input watcher %d for fd %d\n", | |
| 8280 | 109 | closure->result, fd); |
| 8273 | 110 | #endif |
| 111 | ||
| 112 | g_io_channel_unref(channel); | |
| 113 | return closure->result; | |
| 114 | } | |
| 115 | ||
| 116 | static GaimEventLoopUiOps eventloop_ops = | |
| 117 | { | |
| 118 | g_timeout_add, | |
|
8470
100fc1feea95
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8287
diff
changeset
|
119 | (guint (*)(guint))g_source_remove, |
| 8273 | 120 | gaim_gtk_input_add, |
| 8807 | 121 | (guint (*)(guint))g_source_remove |
| 8273 | 122 | }; |
| 123 | ||
| 124 | GaimEventLoopUiOps * | |
| 125 | gaim_gtk_eventloop_get_ui_ops(void) | |
| 126 | { | |
| 127 | return &eventloop_ops; | |
| 128 | } |