Tue, 04 Oct 2005 02:48:25 +0000
[gaim-migrate @ 13877]
Fix 2 things with notify.c, one was causing warnings about signal
instances, and the other a crash only sometimes on closing a tab.
Also randomly removed redundent if !NULL free() in conversation.c
| 10643 | 1 | /* |
| 2 | * @file gtkstatusbox.c GTK+ Status Selection Widget | |
| 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 "internal.h" | |
| 27 | #include "account.h" | |
| 28 | #include "status.h" | |
| 29 | #include "gtkgaim.h" | |
| 30 | #include "gtkstock.h" | |
| 31 | #include "gtkstatusbox.h" | |
| 32 | ||
| 33 | static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); | |
| 11562 | 34 | static void remove_typing_cb(GtkGaimStatusBox *box); |
| 10643 | 35 | |
| 36 | static void gtk_gaim_status_box_changed(GtkComboBox *box); | |
| 37 | static void gtk_gaim_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition); | |
| 38 | static void gtk_gaim_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); | |
| 39 | static gboolean gtk_gaim_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event); | |
| 40 | static void gtk_gaim_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); | |
| 41 | ||
| 42 | static void (*combo_box_size_request)(GtkWidget *widget, GtkRequisition *requisition); | |
| 43 | static void (*combo_box_size_allocate)(GtkWidget *widget, GtkAllocation *allocation); | |
| 44 | static gboolean (*combo_box_expose_event)(GtkWidget *widget, GdkEventExpose *event); | |
| 45 | static void (*combo_box_forall) (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); | |
| 46 | enum { | |
| 47 | ICON_COLUMN, | |
| 48 | TEXT_COLUMN, | |
| 49 | TITLE_COLUMN, | |
| 50 | DESC_COLUMN, | |
| 51 | TYPE_COLUMN, | |
| 52 | NUM_COLUMNS | |
| 53 | }; | |
| 54 | ||
| 11499 | 55 | enum { |
| 56 | PROP_0, | |
| 57 | PROP_ACCOUNT | |
| 58 | }; | |
| 59 | ||
| 10643 | 60 | static void gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass); |
| 61 | static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box); | |
| 62 | ||
| 63 | GType | |
| 64 | gtk_gaim_status_box_get_type (void) | |
| 65 | { | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
66 | static GType status_box_type = 0; |
| 10643 | 67 | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
68 | if (!status_box_type) |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
69 | { |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
70 | static const GTypeInfo status_box_info = |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
71 | { |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
72 | sizeof (GtkGaimStatusBoxClass), |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
73 | NULL, /* base_init */ |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
74 | NULL, /* base_finalize */ |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
75 | (GClassInitFunc) gtk_gaim_status_box_class_init, |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
76 | NULL, /* class_finalize */ |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
77 | NULL, /* class_data */ |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
78 | sizeof (GtkGaimStatusBox), |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
79 | 0, |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
80 | (GInstanceInitFunc) gtk_gaim_status_box_init |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
81 | }; |
| 10643 | 82 | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
83 | status_box_type = g_type_register_static(GTK_TYPE_COMBO_BOX, |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
84 | "GtkGaimStatusBox", |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
85 | &status_box_info, |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
86 | 0); |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
87 | } |
| 10643 | 88 | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
89 | return status_box_type; |
| 10643 | 90 | } |
| 91 | ||
| 92 | static void | |
| 11499 | 93 | gtk_gaim_status_box_get_property(GObject *object, guint param_id, |
| 94 | GValue *value, GParamSpec *psec) | |
| 95 | { | |
| 96 | GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object); | |
| 97 | ||
| 98 | switch (param_id) { | |
| 99 | case PROP_ACCOUNT: | |
| 100 | g_value_set_pointer(value, statusbox->account); | |
| 101 | break; | |
| 102 | default: | |
| 103 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, psec); | |
| 104 | break; | |
| 105 | } | |
| 106 | } | |
| 107 | ||
| 108 | static void | |
| 109 | gtk_gaim_status_box_set_property(GObject *object, guint param_id, | |
| 110 | const GValue *value, GParamSpec *pspec) | |
| 111 | { | |
| 112 | GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object); | |
| 113 | ||
| 114 | switch (param_id) { | |
| 115 | case PROP_ACCOUNT: | |
| 116 | statusbox->account = g_value_get_pointer(value); | |
| 117 | break; | |
| 118 | default: | |
| 119 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); | |
| 120 | break; | |
| 121 | } | |
| 122 | } | |
| 123 | ||
| 124 | ||
| 125 | static void | |
| 10643 | 126 | gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass) |
| 127 | { | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
128 | GObjectClass *object_class; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
129 | GtkWidgetClass *widget_class; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
130 | GtkComboBoxClass *parent_class = (GtkComboBoxClass*)klass; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
131 | GtkContainerClass *container_class = (GtkContainerClass*)klass; |
| 10643 | 132 | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
133 | parent_class->changed = gtk_gaim_status_box_changed; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
134 | widget_class = (GtkWidgetClass*)klass; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
135 | combo_box_size_request = widget_class->size_request; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
136 | widget_class->size_request = gtk_gaim_status_box_size_request; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
137 | combo_box_size_allocate = widget_class->size_allocate; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
138 | widget_class->size_allocate = gtk_gaim_status_box_size_allocate; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
139 | combo_box_expose_event = widget_class->expose_event; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
140 | widget_class->expose_event = gtk_gaim_status_box_expose_event; |
| 10643 | 141 | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
142 | combo_box_forall = container_class->forall; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
143 | container_class->forall = gtk_gaim_status_box_forall; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
144 | |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
145 | object_class = (GObjectClass *)klass; |
| 11499 | 146 | |
| 147 | object_class->get_property = gtk_gaim_status_box_get_property; | |
| 148 | object_class->set_property = gtk_gaim_status_box_set_property; | |
| 149 | ||
| 150 | g_object_class_install_property(object_class, | |
| 151 | PROP_ACCOUNT, | |
| 152 | g_param_spec_pointer("account", | |
| 153 | "Account", | |
| 154 | "The account, or NULL for all accounts", | |
| 155 | G_PARAM_READWRITE | |
| 156 | ) | |
| 157 | ); | |
| 10643 | 158 | } |
| 159 | ||
| 160 | static void | |
| 161 | gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box) | |
| 162 | { | |
|
10672
225bdbfdc28f
[gaim-migrate @ 12212]
Daniel Atallah <datallah@pidgin.im>
parents:
10661
diff
changeset
|
163 | char *text, *title; |
| 10643 | 164 | char aa_color[8]; |
| 165 | GdkPixbuf *pixbuf; | |
|
10702
55a43c79fd6f
[gaim-migrate @ 12284]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10672
diff
changeset
|
166 | GtkTreePath *path; |
| 10643 | 167 | |
| 168 | GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box)); | |
| 169 | snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", | |
| 170 | style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
| 171 | style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
| 172 | style->text_aa[GTK_STATE_NORMAL].blue >> 8); | |
|
10672
225bdbfdc28f
[gaim-migrate @ 12212]
Daniel Atallah <datallah@pidgin.im>
parents:
10661
diff
changeset
|
173 | |
|
225bdbfdc28f
[gaim-migrate @ 12212]
Daniel Atallah <datallah@pidgin.im>
parents:
10661
diff
changeset
|
174 | title = status_box->title; |
|
225bdbfdc28f
[gaim-migrate @ 12212]
Daniel Atallah <datallah@pidgin.im>
parents:
10661
diff
changeset
|
175 | if (!title) |
|
225bdbfdc28f
[gaim-migrate @ 12212]
Daniel Atallah <datallah@pidgin.im>
parents:
10661
diff
changeset
|
176 | title = ""; |
|
225bdbfdc28f
[gaim-migrate @ 12212]
Daniel Atallah <datallah@pidgin.im>
parents:
10661
diff
changeset
|
177 | |
| 10643 | 178 | if (status_box->error) { |
| 11499 | 179 | text = g_strdup_printf("%s\n<span size=\"smaller\" weight=\"bold\" color=\"red\">%s</span>", |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
180 | title, status_box->error); |
| 10643 | 181 | } else if (status_box->typing) { |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
182 | text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>", |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
183 | title, aa_color, _("Typing")); |
| 10643 | 184 | } else if (status_box->connecting) { |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
185 | text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>", |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
186 | title, aa_color, _("Connecting")); |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
187 | } else if (status_box->desc) { |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
188 | text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>", |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
189 | title, aa_color, status_box->desc); |
| 10643 | 190 | } else { |
|
10672
225bdbfdc28f
[gaim-migrate @ 12212]
Daniel Atallah <datallah@pidgin.im>
parents:
10661
diff
changeset
|
191 | text = g_strdup_printf("%s", title); |
| 10643 | 192 | } |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
193 | |
| 11523 | 194 | if (status_box->connecting) |
| 195 | pixbuf = status_box->connecting_pixbufs[status_box->connecting_index]; | |
| 196 | else if (status_box->error) | |
| 10643 | 197 | pixbuf = status_box->error_pixbuf; |
| 198 | else if (status_box->typing) | |
| 199 | pixbuf = status_box->typing_pixbufs[status_box->typing_index]; | |
| 200 | else | |
| 201 | pixbuf = status_box->pixbuf; | |
| 202 | ||
| 203 | gtk_list_store_set(status_box->store, &(status_box->iter), | |
| 204 | ICON_COLUMN, pixbuf, | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
205 | TEXT_COLUMN, text, |
|
10672
225bdbfdc28f
[gaim-migrate @ 12212]
Daniel Atallah <datallah@pidgin.im>
parents:
10661
diff
changeset
|
206 | TITLE_COLUMN, title, |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
207 | DESC_COLUMN, status_box->desc, |
| 10643 | 208 | TYPE_COLUMN, NULL, -1); |
|
10702
55a43c79fd6f
[gaim-migrate @ 12284]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10672
diff
changeset
|
209 | path = gtk_tree_path_new_from_string("0"); |
|
55a43c79fd6f
[gaim-migrate @ 12284]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10672
diff
changeset
|
210 | gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), path); |
|
55a43c79fd6f
[gaim-migrate @ 12284]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10672
diff
changeset
|
211 | gtk_tree_path_free(path); |
| 10643 | 212 | |
| 213 | g_free(text); | |
| 214 | } | |
| 215 | ||
| 216 | static void | |
| 217 | gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) | |
| 218 | { | |
| 11400 | 219 | GtkCellRenderer *text_rend; |
| 220 | GtkCellRenderer *icon_rend; | |
| 10643 | 221 | GtkTextBuffer *buffer; |
| 222 | GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4; | |
| 11400 | 223 | GtkIconSize icon_size; |
| 11593 | 224 | GtkTreePath *path; |
| 11400 | 225 | |
| 226 | text_rend = gtk_cell_renderer_text_new(); | |
| 227 | icon_rend = gtk_cell_renderer_pixbuf_new(); | |
| 228 | icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); | |
| 10643 | 229 | |
| 230 | status_box->imhtml_visible = FALSE; | |
| 231 | status_box->error_pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_OFFLINE, | |
| 232 | icon_size, "GtkGaimStatusBox"); | |
| 233 | status_box->connecting_index = 0; | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
234 | status_box->connecting_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT0, |
| 10643 | 235 | icon_size, "GtkGaimStatusBox"); |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
236 | status_box->connecting_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT1, |
| 10643 | 237 | icon_size, "GtkGaimStatusBox"); |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
238 | status_box->connecting_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT2, |
| 10643 | 239 | icon_size, "GtkGaimStatusBox"); |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
240 | status_box->connecting_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT3, |
| 10643 | 241 | icon_size, "GtkGaimStatusBox"); |
| 242 | ||
| 243 | status_box->typing_index = 0; | |
| 244 | status_box->typing_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING0, | |
| 245 | icon_size, "GtkGaimStatusBox"); | |
| 246 | status_box->typing_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING1, | |
| 247 | icon_size, "GtkGaimStatusBox"); | |
| 248 | status_box->typing_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING2, | |
| 249 | icon_size, "GtkGaimStatusBox"); | |
| 250 | status_box->typing_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING3, | |
| 251 | icon_size, "GtkGaimStatusBox"); | |
| 252 | status_box->connecting = FALSE; | |
| 253 | status_box->typing = FALSE; | |
| 254 | status_box->title = NULL; | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
255 | status_box->pixbuf = NULL; |
| 10643 | 256 | status_box->cell_view = gtk_cell_view_new(); |
| 257 | gtk_widget_show (status_box->cell_view); | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
258 | |
| 10643 | 259 | status_box->store = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); |
| 260 | status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); | |
| 261 | gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); | |
| 262 | gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); | |
| 263 | gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0); | |
| 264 | gtk_list_store_append(status_box->store, &(status_box->iter)); | |
| 265 | gtk_gaim_status_box_refresh(status_box); | |
| 11593 | 266 | path = gtk_tree_path_new_from_string("0"); |
| 267 | gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), path); | |
| 268 | gtk_tree_path_free(path); | |
| 10643 | 269 | gtk_container_add(GTK_CONTAINER(status_box), status_box->cell_view); |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
270 | |
| 10643 | 271 | status_box->icon_rend = gtk_cell_renderer_pixbuf_new(); |
| 272 | status_box->text_rend = gtk_cell_renderer_text_new(); | |
| 273 | ||
| 274 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), icon_rend, FALSE); | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
275 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE); |
| 10643 | 276 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL); |
| 277 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL); | |
| 278 | ||
| 279 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); | |
| 11499 | 280 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); |
| 10643 | 281 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); |
| 282 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); | |
| 283 | ||
| 284 | status_box->vbox = gtk_vbox_new(0, FALSE); | |
| 285 | status_box->imhtml = gtk_imhtml_new(NULL, NULL); | |
| 286 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml)); | |
| 287 | g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(imhtml_changed_cb), status_box); | |
| 11562 | 288 | g_signal_connect_swapped(G_OBJECT(status_box->imhtml), "message_send", G_CALLBACK(remove_typing_cb), status_box); |
| 10643 | 289 | gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE); |
| 290 | gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); | |
| 291 | status_box->sw = gtk_scrolled_window_new(NULL, NULL); | |
| 292 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(status_box->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
| 293 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(status_box->sw), GTK_SHADOW_IN); | |
| 294 | gtk_container_add(GTK_CONTAINER(status_box->sw), status_box->imhtml); | |
| 295 | gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); | |
| 296 | pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_ONLINE, | |
| 297 | icon_size, "GtkGaimStatusBox"); | |
| 298 | pixbuf2 = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_AWAY, | |
| 299 | icon_size, "GtkGaimStatusBox"); | |
| 300 | pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_OFFLINE, | |
| 301 | icon_size, "GtkGaimStatusBox"); | |
| 302 | pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_INVISIBLE, | |
| 303 | icon_size, "GtkGaimStatusBox"); | |
| 304 | /* hacks */ | |
| 305 | gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Available"), NULL, "available"); | |
| 306 | gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf2, _("Away"), NULL, "away"); | |
| 307 | gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf4, _("Invisible"), NULL, "invisible"); | |
| 308 | gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf3, _("Offline"), NULL, "offline"); | |
|
11306
13b99869301f
[gaim-migrate @ 13506]
Mark Doliner <markdoliner@pidgin.im>
parents:
10861
diff
changeset
|
309 | /* |
|
13b99869301f
[gaim-migrate @ 13506]
Mark Doliner <markdoliner@pidgin.im>
parents:
10861
diff
changeset
|
310 | * TODO: This triggers a callback of gaim_gtk_status_box_changed(). |
|
13b99869301f
[gaim-migrate @ 13506]
Mark Doliner <markdoliner@pidgin.im>
parents:
10861
diff
changeset
|
311 | * That's bad. We should at least try not figure out what |
|
13b99869301f
[gaim-migrate @ 13506]
Mark Doliner <markdoliner@pidgin.im>
parents:
10861
diff
changeset
|
312 | * status the user's accounts are set to instead of always |
|
13b99869301f
[gaim-migrate @ 13506]
Mark Doliner <markdoliner@pidgin.im>
parents:
10861
diff
changeset
|
313 | * using "Available." |
|
13b99869301f
[gaim-migrate @ 13506]
Mark Doliner <markdoliner@pidgin.im>
parents:
10861
diff
changeset
|
314 | */ |
|
11347
5b88acc51c32
[gaim-migrate @ 13564]
Mark Doliner <markdoliner@pidgin.im>
parents:
11306
diff
changeset
|
315 | /* gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); */ |
| 10643 | 316 | |
| 317 | } | |
| 318 | ||
| 319 | ||
| 320 | static void | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
321 | gtk_gaim_status_box_size_request(GtkWidget *widget, |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
322 | GtkRequisition *requisition) |
| 10643 | 323 | { |
| 324 | GtkRequisition box_req; | |
| 325 | combo_box_size_request(widget, requisition); | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
326 | |
| 10643 | 327 | gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); |
| 328 | if (box_req.height > 1) | |
| 329 | requisition->height = requisition->height + box_req.height + 6; | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
330 | |
| 10643 | 331 | requisition->width = 1; |
| 332 | ||
| 333 | } | |
| 334 | ||
| 335 | static void | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
336 | gtk_gaim_status_box_size_allocate(GtkWidget *widget, |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
337 | GtkAllocation *allocation) |
| 10643 | 338 | { |
| 339 | GtkRequisition req = {0,0}; | |
| 11400 | 340 | GtkAllocation parent_alc, box_alc; |
| 341 | ||
| 342 | parent_alc = *allocation; | |
| 343 | box_alc = *allocation; | |
| 10643 | 344 | combo_box_size_request(widget, &req); |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
345 | |
| 10643 | 346 | /* EVIL XXX */ |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
347 | box_alc.height = 80; |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
348 | /* box_alc.height = MAX(1,box_alc.height - req.height - 6); */ |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
349 | |
| 10643 | 350 | box_alc.y = box_alc.y + req.height + 6; |
| 351 | gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->vbox, &box_alc); | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
352 | |
| 10643 | 353 | parent_alc.height = MAX(1,req.height); |
| 354 | combo_box_size_allocate(widget, &parent_alc); | |
| 355 | widget->allocation = *allocation; | |
| 356 | } | |
| 357 | ||
| 358 | ||
| 359 | static gboolean | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
360 | gtk_gaim_status_box_expose_event(GtkWidget *widget, |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
361 | GdkEventExpose *event) |
| 10643 | 362 | { |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
363 | GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
364 | combo_box_expose_event(widget, event); |
| 10643 | 365 | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
366 | gtk_container_propagate_expose(GTK_CONTAINER(widget), |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
367 | status_box->vbox, event); |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
368 | return FALSE; |
| 10643 | 369 | } |
| 370 | ||
| 371 | static void | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
372 | gtk_gaim_status_box_forall(GtkContainer *container, |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
373 | gboolean include_internals, |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
374 | GtkCallback callback, |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
375 | gpointer callback_data) |
| 10643 | 376 | { |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
377 | GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (container); |
| 10643 | 378 | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
379 | if (include_internals) |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
380 | { |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
381 | (* callback) (status_box->vbox, callback_data); |
|
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
382 | } |
| 10643 | 383 | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
384 | combo_box_forall(container, include_internals, callback, callback_data); |
| 10643 | 385 | } |
| 386 | ||
| 387 | GtkWidget * | |
| 388 | gtk_gaim_status_box_new() | |
| 389 | { | |
| 390 | return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL); | |
| 391 | } | |
| 392 | ||
| 11499 | 393 | GtkWidget * |
| 394 | gtk_gaim_status_box_new_with_account(GaimAccount *account) | |
| 395 | { | |
| 396 | return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", account, NULL); | |
| 397 | } | |
| 10643 | 398 | |
| 399 | void | |
| 400 | gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, char *edit) | |
| 401 | { | |
| 402 | GtkTreeIter iter; | |
| 403 | char *t; | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
404 | |
| 10643 | 405 | if (sec_text) { |
| 406 | char aa_color[8]; | |
| 407 | GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box)); | |
| 408 | snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", | |
| 409 | style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
| 410 | style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
411 | style->text_aa[GTK_STATE_NORMAL].blue >> 8); |
| 10643 | 412 | t = g_strdup_printf("%s\n<span color=\"%s\">%s</span>", text, aa_color, sec_text); |
| 413 | } else { | |
| 414 | t = g_strdup(text); | |
| 415 | } | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
416 | |
| 10643 | 417 | gtk_list_store_append(status_box->dropdown_store, &iter); |
| 418 | gtk_list_store_set(status_box->dropdown_store, &iter, | |
| 419 | ICON_COLUMN, pixbuf, | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
420 | TEXT_COLUMN, t, |
| 10643 | 421 | TITLE_COLUMN, text, |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
422 | DESC_COLUMN, sec_text, |
| 10643 | 423 | TYPE_COLUMN, edit, -1); |
| 424 | } | |
| 425 | ||
| 426 | void | |
| 427 | gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error) | |
| 428 | { | |
| 11523 | 429 | if (status_box->error) |
| 430 | g_free(status_box->error); | |
| 10643 | 431 | status_box->error = g_strdup(error); |
| 432 | gtk_gaim_status_box_refresh(status_box); | |
| 433 | } | |
| 434 | ||
| 435 | void | |
| 436 | gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting) | |
| 437 | { | |
| 438 | if (!status_box) | |
| 439 | return; | |
| 440 | status_box->connecting = connecting; | |
| 441 | gtk_gaim_status_box_refresh(status_box); | |
| 442 | } | |
| 443 | ||
| 444 | void | |
| 445 | gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box) | |
| 446 | { | |
| 447 | if (!status_box) | |
| 448 | return; | |
| 449 | if (status_box->connecting_index == 3) | |
| 450 | status_box->connecting_index = 0; | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
451 | else |
| 10643 | 452 | status_box->connecting_index++; |
| 453 | gtk_gaim_status_box_refresh(status_box); | |
| 454 | } | |
| 455 | ||
| 456 | void | |
| 457 | gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box) | |
| 458 | { | |
| 459 | if (status_box->typing_index == 3) | |
| 460 | status_box->typing_index = 0; | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
461 | else |
| 10643 | 462 | status_box->typing_index++; |
| 463 | gtk_gaim_status_box_refresh(status_box); | |
| 464 | } | |
| 465 | ||
| 466 | static void remove_typing_cb(GtkGaimStatusBox *box) | |
| 467 | { | |
| 468 | gchar *status_type_id; | |
| 469 | GList *l; | |
| 470 | GtkTreeIter iter; | |
| 471 | ||
| 472 | gtk_combo_box_get_active_iter(GTK_COMBO_BOX(box), &iter); | |
| 473 | gtk_tree_model_get(GTK_TREE_MODEL(box->dropdown_store), &iter, TYPE_COLUMN, &status_type_id, -1); | |
| 474 | for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { | |
| 475 | GaimAccount *account = (GaimAccount*)l->data; | |
| 476 | GaimStatusType *status_type; | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
477 | |
| 10643 | 478 | if (!gaim_account_get_enabled(account, GAIM_GTK_UI)) |
| 479 | continue; | |
| 480 | ||
| 481 | status_type = gaim_account_get_status_type(account, status_type_id); | |
| 482 | ||
| 483 | if (status_type == NULL) | |
| 484 | continue; | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
485 | gaim_account_set_status(account, status_type_id, TRUE, |
| 10643 | 486 | "message",gtk_imhtml_get_markup(GTK_IMHTML(box->imhtml)), NULL); |
| 487 | } | |
| 488 | g_source_remove(box->typing); | |
| 489 | box->typing = 0; | |
| 490 | gtk_gaim_status_box_refresh(box); | |
| 491 | } | |
| 492 | ||
| 493 | static void gtk_gaim_status_box_changed(GtkComboBox *box) | |
| 494 | { | |
| 11400 | 495 | GtkGaimStatusBox *status_box; |
| 10643 | 496 | GtkTreeIter iter; |
| 497 | char *text, *sec_text; | |
| 498 | GdkPixbuf *pixbuf; | |
| 499 | gchar *status_type_id; | |
| 500 | GList *l; | |
| 501 | ||
| 11400 | 502 | status_box = GTK_GAIM_STATUS_BOX(box); |
| 503 | ||
| 10643 | 504 | gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); |
| 505 | gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, TITLE_COLUMN, &text, | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
506 | DESC_COLUMN, &sec_text, ICON_COLUMN, &pixbuf, |
| 10643 | 507 | TYPE_COLUMN, &status_type_id, -1); |
| 508 | if (status_box->title) | |
| 509 | g_free(status_box->title); | |
| 510 | status_box->title = g_strdup(text); | |
| 511 | if (status_box->desc && sec_text) | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
512 | g_free(status_box->desc); |
| 10643 | 513 | status_box->desc = g_strdup(sec_text); |
| 514 | if (status_box->pixbuf) | |
| 515 | g_object_unref(status_box->pixbuf); | |
| 516 | status_box->pixbuf = pixbuf; | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
517 | |
| 10643 | 518 | if (!strcmp(status_type_id, "away")) { |
| 519 | gtk_widget_show_all(status_box->vbox); | |
| 520 | status_box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, status_box); | |
| 521 | gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); | |
| 522 | gtk_widget_grab_focus(status_box->imhtml); | |
| 523 | } else { | |
| 524 | if (status_box->typing) { | |
| 525 | g_source_remove(status_box->typing); | |
| 526 | status_box->typing = 0; | |
| 527 | } | |
| 528 | gtk_widget_hide_all(status_box->vbox); | |
| 529 | for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { | |
| 530 | GaimAccount *account = (GaimAccount*)l->data; | |
| 531 | GaimStatusType *status_type; | |
| 532 | ||
| 533 | if (!gaim_account_get_enabled(account, GAIM_GTK_UI)) | |
| 534 | continue; | |
| 535 | ||
| 536 | status_type = gaim_account_get_status_type(account, status_type_id); | |
| 537 | ||
| 538 | if (status_type == NULL) | |
| 539 | continue; | |
| 540 | gaim_account_set_status(account, status_type_id, TRUE, NULL); | |
| 541 | } | |
| 542 | } | |
| 543 | gtk_gaim_status_box_refresh(status_box); | |
| 544 | } | |
| 545 | ||
| 546 | static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data) | |
| 547 | { | |
| 548 | GtkGaimStatusBox *box = (GtkGaimStatusBox*)data; | |
| 549 | if (box->typing) { | |
| 550 | gtk_gaim_status_box_pulse_typing(box); | |
| 551 | g_source_remove(box->typing); | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
552 | } |
| 10643 | 553 | box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box); |
| 554 | gtk_gaim_status_box_refresh(box); | |
| 555 | } | |
| 10649 | 556 | |
| 557 | const char *gtk_gaim_status_box_get_active_type(GtkGaimStatusBox *status_box) | |
| 558 | { | |
| 559 | GtkTreeIter iter; | |
| 560 | char *type; | |
| 561 | gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); | |
|
10861
21977f46cdf4
[gaim-migrate @ 12544]
Mark Doliner <markdoliner@pidgin.im>
parents:
10749
diff
changeset
|
562 | gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
| 10649 | 563 | TYPE_COLUMN, &type, -1); |
| 564 | return type; | |
| 565 | } | |
| 566 | ||
| 567 | const char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box) | |
| 568 | { | |
| 569 | if (status_box->imhtml_visible) | |
| 570 | return gtk_imhtml_get_markup(GTK_IMHTML(status_box->imhtml)); | |
| 571 | else | |
| 572 | return NULL; | |
| 573 | } |