| 63 |
63 |
| 64 #define TYPING_TIMEOUT 4000 |
64 #define TYPING_TIMEOUT 4000 |
| 65 |
65 |
| 66 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); |
66 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); |
| 67 static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data); |
67 static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data); |
| 68 static void remove_typing_cb(GtkGaimStatusBox *box); |
68 static void remove_typing_cb(PidginStatusBox *box); |
| 69 static void update_size (GtkGaimStatusBox *box); |
69 static void update_size (PidginStatusBox *box); |
| 70 static gint get_statusbox_index(GtkGaimStatusBox *box, GaimSavedStatus *saved_status); |
70 static gint get_statusbox_index(PidginStatusBox *box, GaimSavedStatus *saved_status); |
| 71 |
71 |
| 72 static void gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box); |
72 static void pidgin_status_box_pulse_typing(PidginStatusBox *status_box); |
| 73 static void gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box); |
73 static void pidgin_status_box_refresh(PidginStatusBox *status_box); |
| 74 static void status_menu_refresh_iter(GtkGaimStatusBox *status_box); |
74 static void status_menu_refresh_iter(PidginStatusBox *status_box); |
| 75 static void gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box); |
75 static void pidgin_status_box_regenerate(PidginStatusBox *status_box); |
| 76 static void gtk_gaim_status_box_changed(GtkGaimStatusBox *box); |
76 static void pidgin_status_box_changed(PidginStatusBox *box); |
| 77 static void gtk_gaim_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition); |
77 static void pidgin_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition); |
| 78 static void gtk_gaim_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); |
78 static void pidgin_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); |
| 79 static gboolean gtk_gaim_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event); |
79 static gboolean pidgin_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event); |
| 80 static void gtk_gaim_status_box_redisplay_buddy_icon(GtkGaimStatusBox *status_box); |
80 static void pidgin_status_box_redisplay_buddy_icon(PidginStatusBox *status_box); |
| 81 static void gtk_gaim_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); |
81 static void pidgin_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); |
| 82 static void pidgin_status_box_popup(GtkGaimStatusBox *box); |
82 static void pidgin_status_box_popup(PidginStatusBox *box); |
| 83 static void pidgin_status_box_popdown(GtkGaimStatusBox *box); |
83 static void pidgin_status_box_popdown(PidginStatusBox *box); |
| 84 |
84 |
| 85 static void do_colorshift (GdkPixbuf *dest, GdkPixbuf *src, int shift); |
85 static void do_colorshift (GdkPixbuf *dest, GdkPixbuf *src, int shift); |
| 86 static void icon_choose_cb(const char *filename, gpointer data); |
86 static void icon_choose_cb(const char *filename, gpointer data); |
| 87 static void remove_buddy_icon_cb(GtkWidget *w, GtkGaimStatusBox *box); |
87 static void remove_buddy_icon_cb(GtkWidget *w, PidginStatusBox *box); |
| 88 |
88 |
| 89 enum { |
89 enum { |
| 90 /** A GtkGaimStatusBoxItemType */ |
90 /** A PidginStatusBoxItemType */ |
| 91 TYPE_COLUMN, |
91 TYPE_COLUMN, |
| 92 |
92 |
| 93 /** |
93 /** |
| 94 * This is a GdkPixbuf (the other columns are strings). |
94 * This is a GdkPixbuf (the other columns are strings). |
| 95 * This column is visible. |
95 * This column is visible. |
| 121 PROP_ICON_SEL, |
121 PROP_ICON_SEL, |
| 122 }; |
122 }; |
| 123 |
123 |
| 124 GtkContainerClass *parent_class = NULL; |
124 GtkContainerClass *parent_class = NULL; |
| 125 |
125 |
| 126 static void gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass); |
126 static void pidgin_status_box_class_init (PidginStatusBoxClass *klass); |
| 127 static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box); |
127 static void pidgin_status_box_init (PidginStatusBox *status_box); |
| 128 |
128 |
| 129 GType |
129 GType |
| 130 gtk_gaim_status_box_get_type (void) |
130 pidgin_status_box_get_type (void) |
| 131 { |
131 { |
| 132 static GType status_box_type = 0; |
132 static GType status_box_type = 0; |
| 133 |
133 |
| 134 if (!status_box_type) |
134 if (!status_box_type) |
| 135 { |
135 { |
| 136 static const GTypeInfo status_box_info = |
136 static const GTypeInfo status_box_info = |
| 137 { |
137 { |
| 138 sizeof (GtkGaimStatusBoxClass), |
138 sizeof (PidginStatusBoxClass), |
| 139 NULL, /* base_init */ |
139 NULL, /* base_init */ |
| 140 NULL, /* base_finalize */ |
140 NULL, /* base_finalize */ |
| 141 (GClassInitFunc) gtk_gaim_status_box_class_init, |
141 (GClassInitFunc) pidgin_status_box_class_init, |
| 142 NULL, /* class_finalize */ |
142 NULL, /* class_finalize */ |
| 143 NULL, /* class_data */ |
143 NULL, /* class_data */ |
| 144 sizeof (GtkGaimStatusBox), |
144 sizeof (PidginStatusBox), |
| 145 0, |
145 0, |
| 146 (GInstanceInitFunc) gtk_gaim_status_box_init, |
146 (GInstanceInitFunc) pidgin_status_box_init, |
| 147 NULL /* value_table */ |
147 NULL /* value_table */ |
| 148 }; |
148 }; |
| 149 |
149 |
| 150 status_box_type = g_type_register_static(GTK_TYPE_CONTAINER, |
150 status_box_type = g_type_register_static(GTK_TYPE_CONTAINER, |
| 151 "GtkGaimStatusBox", |
151 "PidginStatusBox", |
| 152 &status_box_info, |
152 &status_box_info, |
| 153 0); |
153 0); |
| 154 } |
154 } |
| 155 |
155 |
| 156 return status_box_type; |
156 return status_box_type; |
| 157 } |
157 } |
| 158 |
158 |
| 159 static void |
159 static void |
| 160 gtk_gaim_status_box_get_property(GObject *object, guint param_id, |
160 pidgin_status_box_get_property(GObject *object, guint param_id, |
| 161 GValue *value, GParamSpec *psec) |
161 GValue *value, GParamSpec *psec) |
| 162 { |
162 { |
| 163 GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object); |
163 PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(object); |
| 164 |
164 |
| 165 switch (param_id) { |
165 switch (param_id) { |
| 166 case PROP_ACCOUNT: |
166 case PROP_ACCOUNT: |
| 167 g_value_set_pointer(value, statusbox->account); |
167 g_value_set_pointer(value, statusbox->account); |
| 168 break; |
168 break; |
| 219 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); |
219 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); |
| 220 gtk_imhtml_clear_formatting(GTK_IMHTML(status_box->imhtml)); |
220 gtk_imhtml_clear_formatting(GTK_IMHTML(status_box->imhtml)); |
| 221 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); |
221 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); |
| 222 } |
222 } |
| 223 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); |
223 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); |
| 224 gtk_gaim_status_box_refresh(status_box); |
224 pidgin_status_box_refresh(status_box); |
| 225 } |
225 } |
| 226 } |
226 } |
| 227 |
227 |
| 228 static void |
228 static void |
| 229 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, GaimStatus *newstatus, GtkGaimStatusBox *status_box) |
229 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, GaimStatus *newstatus, PidginStatusBox *status_box) |
| 230 { |
230 { |
| 231 if (status_box->account == account) |
231 if (status_box->account == account) |
| 232 update_to_reflect_account_status(status_box, account, newstatus); |
232 update_to_reflect_account_status(status_box, account, newstatus); |
| 233 else if (status_box->token_status_account == account) |
233 else if (status_box->token_status_account == account) |
| 234 status_menu_refresh_iter(status_box); |
234 status_menu_refresh_iter(status_box); |
| 235 } |
235 } |
| 236 |
236 |
| 237 static gboolean |
237 static gboolean |
| 238 icon_box_press_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) |
238 icon_box_press_cb(GtkWidget *widget, GdkEventButton *event, PidginStatusBox *box) |
| 239 { |
239 { |
| 240 if (event->button == 3) { |
240 if (event->button == 3) { |
| 241 GtkWidget *menu_item; |
241 GtkWidget *menu_item; |
| 242 |
242 |
| 243 if (box->icon_box_menu) |
243 if (box->icon_box_menu) |
| 266 return FALSE; |
266 return FALSE; |
| 267 } |
267 } |
| 268 |
268 |
| 269 static void |
269 static void |
| 270 icon_box_dnd_cb(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
270 icon_box_dnd_cb(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
| 271 GtkSelectionData *sd, guint info, guint t, GtkGaimStatusBox *box) |
271 GtkSelectionData *sd, guint info, guint t, PidginStatusBox *box) |
| 272 { |
272 { |
| 273 gchar *name = (gchar *)sd->data; |
273 gchar *name = (gchar *)sd->data; |
| 274 |
274 |
| 275 if ((sd->length >= 0) && (sd->format == 8)) { |
275 if ((sd->length >= 0) && (sd->format == 8)) { |
| 276 /* Well, it looks like the drag event was cool. |
276 /* Well, it looks like the drag event was cool. |
| 295 gtk_drag_finish(dc, FALSE, FALSE, t); |
295 gtk_drag_finish(dc, FALSE, FALSE, t); |
| 296 } |
296 } |
| 297 |
297 |
| 298 |
298 |
| 299 static gboolean |
299 static gboolean |
| 300 icon_box_enter_cb(GtkWidget *widget, GdkEventCrossing *event, GtkGaimStatusBox *box) |
300 icon_box_enter_cb(GtkWidget *widget, GdkEventCrossing *event, PidginStatusBox *box) |
| 301 { |
301 { |
| 302 gdk_window_set_cursor(widget->window, box->hand_cursor); |
302 gdk_window_set_cursor(widget->window, box->hand_cursor); |
| 303 gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon_hover); |
303 gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon_hover); |
| 304 return FALSE; |
304 return FALSE; |
| 305 } |
305 } |
| 306 |
306 |
| 307 static gboolean |
307 static gboolean |
| 308 icon_box_leave_cb(GtkWidget *widget, GdkEventCrossing *event, GtkGaimStatusBox *box) |
308 icon_box_leave_cb(GtkWidget *widget, GdkEventCrossing *event, PidginStatusBox *box) |
| 309 { |
309 { |
| 310 gdk_window_set_cursor(widget->window, box->arrow_cursor); |
310 gdk_window_set_cursor(widget->window, box->arrow_cursor); |
| 311 gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon) ; |
311 gtk_image_set_from_pixbuf(GTK_IMAGE(box->icon), box->buddy_icon) ; |
| 312 return FALSE; |
312 return FALSE; |
| 313 } |
313 } |
| 332 |
332 |
| 333 if (status_box->account && |
333 if (status_box->account && |
| 334 !gaim_account_get_bool(status_box->account, "use-global-buddyicon", TRUE)) |
334 !gaim_account_get_bool(status_box->account, "use-global-buddyicon", TRUE)) |
| 335 { |
335 { |
| 336 char *string = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(status_box->account)); |
336 char *string = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(status_box->account)); |
| 337 gtk_gaim_status_box_set_buddy_icon(status_box, string); |
337 pidgin_status_box_set_buddy_icon(status_box, string); |
| 338 g_free(string); |
338 g_free(string); |
| 339 } |
339 } |
| 340 else |
340 else |
| 341 { |
341 { |
| 342 gtk_gaim_status_box_set_buddy_icon(status_box, gaim_prefs_get_path("/gaim/gtk/accounts/buddyicon")); |
342 pidgin_status_box_set_buddy_icon(status_box, gaim_prefs_get_path("/gaim/gtk/accounts/buddyicon")); |
| 343 } |
343 } |
| 344 |
344 |
| 345 status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); |
345 status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); |
| 346 status_box->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
346 status_box->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
| 347 |
347 |
| 417 } |
417 } |
| 418 break; |
418 break; |
| 419 case PROP_ACCOUNT: |
419 case PROP_ACCOUNT: |
| 420 statusbox->account = g_value_get_pointer(value); |
420 statusbox->account = g_value_get_pointer(value); |
| 421 |
421 |
| 422 gtk_gaim_status_box_regenerate(statusbox); |
422 pidgin_status_box_regenerate(statusbox); |
| 423 |
423 |
| 424 break; |
424 break; |
| 425 default: |
425 default: |
| 426 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); |
426 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); |
| 427 break; |
427 break; |
| 428 } |
428 } |
| 429 } |
429 } |
| 430 |
430 |
| 431 static void |
431 static void |
| 432 gtk_gaim_status_box_finalize(GObject *obj) |
432 pidgin_status_box_finalize(GObject *obj) |
| 433 { |
433 { |
| 434 GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(obj); |
434 PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(obj); |
| 435 |
435 |
| 436 gaim_signals_disconnect_by_handle(statusbox); |
436 gaim_signals_disconnect_by_handle(statusbox); |
| 437 gaim_prefs_disconnect_by_handle(statusbox); |
437 gaim_prefs_disconnect_by_handle(statusbox); |
| 438 |
438 |
| 439 gdk_cursor_unref(statusbox->hand_cursor); |
439 gdk_cursor_unref(statusbox->hand_cursor); |
| 449 |
449 |
| 450 G_OBJECT_CLASS(parent_class)->finalize(obj); |
450 G_OBJECT_CLASS(parent_class)->finalize(obj); |
| 451 } |
451 } |
| 452 |
452 |
| 453 static GType |
453 static GType |
| 454 gtk_gaim_status_box_child_type (GtkContainer *container) |
454 pidgin_status_box_child_type (GtkContainer *container) |
| 455 { |
455 { |
| 456 return GTK_TYPE_WIDGET; |
456 return GTK_TYPE_WIDGET; |
| 457 } |
457 } |
| 458 |
458 |
| 459 static void |
459 static void |
| 460 gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass) |
460 pidgin_status_box_class_init (PidginStatusBoxClass *klass) |
| 461 { |
461 { |
| 462 GObjectClass *object_class; |
462 GObjectClass *object_class; |
| 463 GtkWidgetClass *widget_class; |
463 GtkWidgetClass *widget_class; |
| 464 GtkContainerClass *container_class = (GtkContainerClass*)klass; |
464 GtkContainerClass *container_class = (GtkContainerClass*)klass; |
| 465 |
465 |
| 466 parent_class = g_type_class_peek_parent(klass); |
466 parent_class = g_type_class_peek_parent(klass); |
| 467 |
467 |
| 468 widget_class = (GtkWidgetClass*)klass; |
468 widget_class = (GtkWidgetClass*)klass; |
| 469 widget_class->size_request = gtk_gaim_status_box_size_request; |
469 widget_class->size_request = pidgin_status_box_size_request; |
| 470 widget_class->size_allocate = gtk_gaim_status_box_size_allocate; |
470 widget_class->size_allocate = pidgin_status_box_size_allocate; |
| 471 widget_class->expose_event = gtk_gaim_status_box_expose_event; |
471 widget_class->expose_event = pidgin_status_box_expose_event; |
| 472 |
472 |
| 473 container_class->child_type = gtk_gaim_status_box_child_type; |
473 container_class->child_type = pidgin_status_box_child_type; |
| 474 container_class->forall = gtk_gaim_status_box_forall; |
474 container_class->forall = pidgin_status_box_forall; |
| 475 container_class->remove = NULL; |
475 container_class->remove = NULL; |
| 476 |
476 |
| 477 object_class = (GObjectClass *)klass; |
477 object_class = (GObjectClass *)klass; |
| 478 |
478 |
| 479 object_class->finalize = gtk_gaim_status_box_finalize; |
479 object_class->finalize = pidgin_status_box_finalize; |
| 480 |
480 |
| 481 object_class->get_property = gtk_gaim_status_box_get_property; |
481 object_class->get_property = pidgin_status_box_get_property; |
| 482 object_class->set_property = gtk_gaim_status_box_set_property; |
482 object_class->set_property = pidgin_status_box_set_property; |
| 483 |
483 |
| 484 g_object_class_install_property(object_class, |
484 g_object_class_install_property(object_class, |
| 485 PROP_ACCOUNT, |
485 PROP_ACCOUNT, |
| 486 g_param_spec_pointer("account", |
486 g_param_spec_pointer("account", |
| 487 "Account", |
487 "Account", |
| 893 gaim_util_chrreplace(stripped, '\n', ' '); |
893 gaim_util_chrreplace(stripped, '\n', ' '); |
| 894 } |
894 } |
| 895 #if 0 |
895 #if 0 |
| 896 /* Overlay a disk in the bottom left corner */ |
896 /* Overlay a disk in the bottom left corner */ |
| 897 emblem = gtk_widget_render_icon(GTK_WIDGET(statusbox->vbox), |
897 emblem = gtk_widget_render_icon(GTK_WIDGET(statusbox->vbox), |
| 898 GTK_STOCK_SAVE, icon_size, "GtkGaimStatusBox"); |
898 GTK_STOCK_SAVE, icon_size, "PidginStatusBox"); |
| 899 if (emblem != NULL) |
899 if (emblem != NULL) |
| 900 { |
900 { |
| 901 width = gdk_pixbuf_get_width(pixbuf) / 2; |
901 width = gdk_pixbuf_get_width(pixbuf) / 2; |
| 902 height = gdk_pixbuf_get_height(pixbuf) / 2; |
902 height = gdk_pixbuf_get_height(pixbuf) / 2; |
| 903 gdk_pixbuf_composite(emblem, pixbuf, 0, height, |
903 gdk_pixbuf_composite(emblem, pixbuf, 0, height, |
| 1001 icon_size, "PidginStatusBox"); |
1001 icon_size, "PidginStatusBox"); |
| 1002 else |
1002 else |
| 1003 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_AVAILABLE, |
1003 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_AVAILABLE, |
| 1004 icon_size, "PidginStatusBox"); |
1004 icon_size, "PidginStatusBox"); |
| 1005 |
1005 |
| 1006 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), |
1006 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), |
| 1007 GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf, |
1007 PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf, |
| 1008 gaim_status_type_get_name(status_type), |
1008 gaim_status_type_get_name(status_type), |
| 1009 NULL, |
1009 NULL, |
| 1010 GINT_TO_POINTER(gaim_status_type_get_primitive(status_type))); |
1010 GINT_TO_POINTER(gaim_status_type_get_primitive(status_type))); |
| 1011 if (pixbuf != NULL) |
1011 if (pixbuf != NULL) |
| 1012 g_object_unref(pixbuf); |
1012 g_object_unref(pixbuf); |
| 1013 } |
1013 } |
| 1014 } |
1014 } |
| 1015 |
1015 |
| 1016 static void |
1016 static void |
| 1017 gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box) |
1017 pidgin_status_box_regenerate(PidginStatusBox *status_box) |
| 1018 { |
1018 { |
| 1019 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4; |
1019 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4; |
| 1020 GtkIconSize icon_size; |
1020 GtkIconSize icon_size; |
| 1021 |
1021 |
| 1022 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
1022 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
| 1030 /* gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); */ |
1030 /* gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); */ |
| 1031 |
1031 |
| 1032 if (status_box->account == NULL) |
1032 if (status_box->account == NULL) |
| 1033 { |
1033 { |
| 1034 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_AVAILABLE, |
1034 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_AVAILABLE, |
| 1035 icon_size, "GtkGaimStatusBox"); |
1035 icon_size, "PidginStatusBox"); |
| 1036 /* Do all the currently enabled accounts have the same statuses? |
1036 /* Do all the currently enabled accounts have the same statuses? |
| 1037 * If so, display them instead of our global list. |
1037 * If so, display them instead of our global list. |
| 1038 */ |
1038 */ |
| 1039 if (status_box->token_status_account) { |
1039 if (status_box->token_status_account) { |
| 1040 add_account_statuses(status_box, status_box->token_status_account); |
1040 add_account_statuses(status_box, status_box->token_status_account); |
| 1045 pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_OFFLINE, |
1045 pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_OFFLINE, |
| 1046 icon_size, "PidginStatusBox"); |
1046 icon_size, "PidginStatusBox"); |
| 1047 pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_AVAILABLE_I, |
1047 pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_AVAILABLE_I, |
| 1048 icon_size, "PidginStatusBox"); |
1048 icon_size, "PidginStatusBox"); |
| 1049 |
1049 |
| 1050 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf, _("Available"), NULL, GINT_TO_POINTER(GAIM_STATUS_AVAILABLE)); |
1050 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf, _("Available"), NULL, GINT_TO_POINTER(GAIM_STATUS_AVAILABLE)); |
| 1051 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf2, _("Away"), NULL, GINT_TO_POINTER(GAIM_STATUS_AWAY)); |
1051 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf2, _("Away"), NULL, GINT_TO_POINTER(GAIM_STATUS_AWAY)); |
| 1052 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf4, _("Invisible"), NULL, GINT_TO_POINTER(GAIM_STATUS_INVISIBLE)); |
1052 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf4, _("Invisible"), NULL, GINT_TO_POINTER(GAIM_STATUS_INVISIBLE)); |
| 1053 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE, pixbuf3, _("Offline"), NULL, GINT_TO_POINTER(GAIM_STATUS_OFFLINE)); |
1053 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf3, _("Offline"), NULL, GINT_TO_POINTER(GAIM_STATUS_OFFLINE)); |
| 1054 |
1054 |
| 1055 if (pixbuf2) g_object_unref(G_OBJECT(pixbuf2)); |
1055 if (pixbuf2) g_object_unref(G_OBJECT(pixbuf2)); |
| 1056 if (pixbuf3) g_object_unref(G_OBJECT(pixbuf3)); |
1056 if (pixbuf3) g_object_unref(G_OBJECT(pixbuf3)); |
| 1057 if (pixbuf4) g_object_unref(G_OBJECT(pixbuf4)); |
1057 if (pixbuf4) g_object_unref(G_OBJECT(pixbuf4)); |
| 1058 } |
1058 } |
| 1059 |
1059 |
| 1060 add_popular_statuses(status_box); |
1060 add_popular_statuses(status_box); |
| 1061 |
1061 |
| 1062 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box)); |
1062 pidgin_status_box_add_separator(PIDGIN_STATUS_BOX(status_box)); |
| 1063 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("New..."), NULL, NULL); |
1063 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("New..."), NULL, NULL); |
| 1064 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL, NULL); |
1064 pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL, NULL); |
| 1065 if (pixbuf) g_object_unref(G_OBJECT(pixbuf)); |
1065 if (pixbuf) g_object_unref(G_OBJECT(pixbuf)); |
| 1066 |
1066 |
| 1067 status_menu_refresh_iter(status_box); |
1067 status_menu_refresh_iter(status_box); |
| 1068 gtk_gaim_status_box_refresh(status_box); |
1068 pidgin_status_box_refresh(status_box); |
| 1069 |
1069 |
| 1070 } else { |
1070 } else { |
| 1071 add_account_statuses(status_box, status_box->account); |
1071 add_account_statuses(status_box, status_box->account); |
| 1072 update_to_reflect_account_status(status_box, status_box->account, |
1072 update_to_reflect_account_status(status_box, status_box->account, |
| 1073 gaim_account_get_active_status(status_box->account)); |
1073 gaim_account_get_active_status(status_box->account)); |
| 1113 if (status_box->account != NULL) |
1113 if (status_box->account != NULL) |
| 1114 update_to_reflect_account_status(status_box, status_box->account, |
1114 update_to_reflect_account_status(status_box, status_box->account, |
| 1115 gaim_account_get_active_status(status_box->account)); |
1115 gaim_account_get_active_status(status_box->account)); |
| 1116 else { |
1116 else { |
| 1117 status_menu_refresh_iter(status_box); |
1117 status_menu_refresh_iter(status_box); |
| 1118 gtk_gaim_status_box_refresh(status_box); |
1118 pidgin_status_box_refresh(status_box); |
| 1119 } |
1119 } |
| 1120 return TRUE; |
1120 return TRUE; |
| 1121 } |
1121 } |
| 1122 |
1122 |
| 1123 gtk_gaim_status_box_pulse_typing(status_box); |
1123 pidgin_status_box_pulse_typing(status_box); |
| 1124 g_source_remove(status_box->typing); |
1124 g_source_remove(status_box->typing); |
| 1125 status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); |
1125 status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); |
| 1126 |
1126 |
| 1127 return FALSE; |
1127 return FALSE; |
| 1128 } |
1128 } |
| 1130 #if GTK_CHECK_VERSION(2,6,0) |
1130 #if GTK_CHECK_VERSION(2,6,0) |
| 1131 static gboolean |
1131 static gboolean |
| 1132 dropdown_store_row_separator_func(GtkTreeModel *model, |
1132 dropdown_store_row_separator_func(GtkTreeModel *model, |
| 1133 GtkTreeIter *iter, gpointer data) |
1133 GtkTreeIter *iter, gpointer data) |
| 1134 { |
1134 { |
| 1135 GtkGaimStatusBoxItemType type; |
1135 PidginStatusBoxItemType type; |
| 1136 |
1136 |
| 1137 gtk_tree_model_get(model, iter, TYPE_COLUMN, &type, -1); |
1137 gtk_tree_model_get(model, iter, TYPE_COLUMN, &type, -1); |
| 1138 |
1138 |
| 1139 if (type == GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR) |
1139 if (type == PIDGIN_STATUS_BOX_TYPE_SEPARATOR) |
| 1140 return TRUE; |
1140 return TRUE; |
| 1141 |
1141 |
| 1142 return FALSE; |
1142 return FALSE; |
| 1143 } |
1143 } |
| 1144 #endif |
1144 #endif |
| 1145 |
1145 |
| 1146 static void |
1146 static void |
| 1147 cache_pixbufs(GtkGaimStatusBox *status_box) |
1147 cache_pixbufs(PidginStatusBox *status_box) |
| 1148 { |
1148 { |
| 1149 GtkIconSize icon_size; |
1149 GtkIconSize icon_size; |
| 1150 |
1150 |
| 1151 g_object_set(G_OBJECT(status_box->icon_rend), "xpad", 3, NULL); |
1151 g_object_set(G_OBJECT(status_box->icon_rend), "xpad", 3, NULL); |
| 1152 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
1152 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
| 1188 icon_size, "PidginStatusBox"); |
1188 icon_size, "PidginStatusBox"); |
| 1189 status_box->typing_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_TYPING3, |
1189 status_box->typing_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_ANIMATION_TYPING3, |
| 1190 icon_size, "PidginStatusBox"); |
1190 icon_size, "PidginStatusBox"); |
| 1191 } |
1191 } |
| 1192 |
1192 |
| 1193 static void account_enabled_cb(GaimAccount *acct, GtkGaimStatusBox *status_box) { |
1193 static void account_enabled_cb(GaimAccount *acct, PidginStatusBox *status_box) { |
| 1194 GaimAccount *initial_token_acct = status_box->token_status_account; |
1194 GaimAccount *initial_token_acct = status_box->token_status_account; |
| 1195 |
1195 |
| 1196 status_box->token_status_account = check_active_accounts_for_identical_statuses(); |
1196 status_box->token_status_account = check_active_accounts_for_identical_statuses(); |
| 1197 |
1197 |
| 1198 /* Regenerate the list if it has changed */ |
1198 /* Regenerate the list if it has changed */ |
| 1199 if (initial_token_acct != status_box->token_status_account) { |
1199 if (initial_token_acct != status_box->token_status_account) { |
| 1200 gtk_gaim_status_box_regenerate(status_box); |
1200 pidgin_status_box_regenerate(status_box); |
| 1201 } |
1201 } |
| 1202 |
1202 |
| 1203 } |
1203 } |
| 1204 |
1204 |
| 1205 static void |
1205 static void |
| 1206 current_savedstatus_changed_cb(GaimSavedStatus *now, GaimSavedStatus *old, GtkGaimStatusBox *status_box) |
1206 current_savedstatus_changed_cb(GaimSavedStatus *now, GaimSavedStatus *old, PidginStatusBox *status_box) |
| 1207 { |
1207 { |
| 1208 /* Make sure our current status is added to the list of popular statuses */ |
1208 /* Make sure our current status is added to the list of popular statuses */ |
| 1209 gtk_gaim_status_box_regenerate(status_box); |
1209 pidgin_status_box_regenerate(status_box); |
| 1210 } |
1210 } |
| 1211 |
1211 |
| 1212 static void |
1212 static void |
| 1213 spellcheck_prefs_cb(const char *name, GaimPrefType type, |
1213 spellcheck_prefs_cb(const char *name, GaimPrefType type, |
| 1214 gconstpointer value, gpointer data) |
1214 gconstpointer value, gpointer data) |
| 1215 { |
1215 { |
| 1216 #ifdef USE_GTKSPELL |
1216 #ifdef USE_GTKSPELL |
| 1217 GtkGaimStatusBox *status_box = (GtkGaimStatusBox *)data; |
1217 PidginStatusBox *status_box = (PidginStatusBox *)data; |
| 1218 |
1218 |
| 1219 if (value) |
1219 if (value) |
| 1220 pidgin_setup_gtkspell(GTK_TEXT_VIEW(status_box->imhtml)); |
1220 pidgin_setup_gtkspell(GTK_TEXT_VIEW(status_box->imhtml)); |
| 1221 else |
1221 else |
| 1222 { |
1222 { |
| 1226 } |
1226 } |
| 1227 #endif |
1227 #endif |
| 1228 } |
1228 } |
| 1229 |
1229 |
| 1230 #if 0 |
1230 #if 0 |
| 1231 static gboolean button_released_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) |
1231 static gboolean button_released_cb(GtkWidget *widget, GdkEventButton *event, PidginStatusBox *box) |
| 1232 { |
1232 { |
| 1233 |
1233 |
| 1234 if (event->button != 1) |
1234 if (event->button != 1) |
| 1235 return FALSE; |
1235 return FALSE; |
| 1236 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(box->toggle_button), FALSE); |
1236 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(box->toggle_button), FALSE); |
| 1237 if (!box->imhtml_visible) |
1237 if (!box->imhtml_visible) |
| 1238 g_signal_emit_by_name(G_OBJECT(box), "changed", NULL, NULL); |
1238 g_signal_emit_by_name(G_OBJECT(box), "changed", NULL, NULL); |
| 1239 return TRUE; |
1239 return TRUE; |
| 1240 } |
1240 } |
| 1241 |
1241 |
| 1242 static gboolean button_pressed_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *box) |
1242 static gboolean button_pressed_cb(GtkWidget *widget, GdkEventButton *event, PidginStatusBox *box) |
| 1243 { |
1243 { |
| 1244 if (event->button != 1) |
1244 if (event->button != 1) |
| 1245 return FALSE; |
1245 return FALSE; |
| 1246 gtk_combo_box_popup(GTK_COMBO_BOX(box)); |
1246 gtk_combo_box_popup(GTK_COMBO_BOX(box)); |
| 1247 // Disabled until button_released_cb works |
1247 // Disabled until button_released_cb works |
| 1349 return FALSE; |
1349 return FALSE; |
| 1350 } |
1350 } |
| 1351 |
1351 |
| 1352 |
1352 |
| 1353 static void |
1353 static void |
| 1354 pidgin_status_box_popup(GtkGaimStatusBox *box) |
1354 pidgin_status_box_popup(PidginStatusBox *box) |
| 1355 { |
1355 { |
| 1356 int width, height, x, y; |
1356 int width, height, x, y; |
| 1357 gtk_gaim_status_box_list_position (box, &x, &y, &width, &height); |
1357 pidgin_status_box_list_position (box, &x, &y, &width, &height); |
| 1358 |
1358 |
| 1359 gtk_widget_set_size_request (box->popup_window, width, height); |
1359 gtk_widget_set_size_request (box->popup_window, width, height); |
| 1360 gtk_window_move (GTK_WINDOW (box->popup_window), x, y); |
1360 gtk_window_move (GTK_WINDOW (box->popup_window), x, y); |
| 1361 gtk_widget_show(box->popup_window); |
1361 gtk_widget_show(box->popup_window); |
| 1362 gtk_widget_grab_focus (box->tree_view); |
1362 gtk_widget_grab_focus (box->tree_view); |
| 1376 gtk_tree_path_free(path); |
1376 gtk_tree_path_free(path); |
| 1377 } |
1377 } |
| 1378 } |
1378 } |
| 1379 |
1379 |
| 1380 static void |
1380 static void |
| 1381 pidgin_status_box_popdown(GtkGaimStatusBox *box) { |
1381 pidgin_status_box_popdown(PidginStatusBox *box) { |
| 1382 gtk_widget_hide(box->popup_window); |
1382 gtk_widget_hide(box->popup_window); |
| 1383 box->popup_in_progress = FALSE; |
1383 box->popup_in_progress = FALSE; |
| 1384 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (box->toggle_button), |
1384 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (box->toggle_button), |
| 1385 FALSE); |
1385 FALSE); |
| 1386 gtk_grab_remove (box->popup_window); |
1386 gtk_grab_remove (box->popup_window); |
| 1387 } |
1387 } |
| 1388 |
1388 |
| 1389 |
1389 |
| 1390 static void |
1390 static void |
| 1391 toggled_cb(GtkWidget *widget, GtkGaimStatusBox *box) |
1391 toggled_cb(GtkWidget *widget, PidginStatusBox *box) |
| 1392 { |
1392 { |
| 1393 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { |
1393 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { |
| 1394 if (!box->popup_in_progress) |
1394 if (!box->popup_in_progress) |
| 1395 pidgin_status_box_popup (box); |
1395 pidgin_status_box_popup (box); |
| 1396 } else { |
1396 } else { |
| 1397 pidgin_status_box_popdown(box); |
1397 pidgin_status_box_popdown(box); |
| 1398 } |
1398 } |
| 1399 } |
1399 } |
| 1400 |
1400 |
| 1401 static void |
1401 static void |
| 1402 buddy_icon_set_cb(const char *filename, GtkGaimStatusBox *box) |
1402 buddy_icon_set_cb(const char *filename, PidginStatusBox *box) |
| 1403 { |
1403 { |
| 1404 |
1404 |
| 1405 if (box->account) { |
1405 if (box->account) { |
| 1406 GaimPlugin *plug = gaim_find_prpl(gaim_account_get_protocol_id(box->account)); |
1406 GaimPlugin *plug = gaim_find_prpl(gaim_account_get_protocol_id(box->account)); |
| 1407 if (plug) { |
1407 if (plug) { |
| 1470 |
1470 |
| 1471 static void |
1471 static void |
| 1472 update_buddyicon_cb(const char *name, GaimPrefType type, |
1472 update_buddyicon_cb(const char *name, GaimPrefType type, |
| 1473 gconstpointer value, gpointer data) |
1473 gconstpointer value, gpointer data) |
| 1474 { |
1474 { |
| 1475 buddy_icon_set_cb(value, (GtkGaimStatusBox*) data); |
1475 buddy_icon_set_cb(value, (PidginStatusBox*) data); |
| 1476 } |
1476 } |
| 1477 |
1477 |
| 1478 static void |
1478 static void |
| 1479 treeview_activate_current_selection(GtkGaimStatusBox *status_box, GtkTreePath *path) |
1479 treeview_activate_current_selection(PidginStatusBox *status_box, GtkTreePath *path) |
| 1480 { |
1480 { |
| 1481 if (status_box->active_row) |
1481 if (status_box->active_row) |
| 1482 gtk_tree_row_reference_free(status_box->active_row); |
1482 gtk_tree_row_reference_free(status_box->active_row); |
| 1483 |
1483 |
| 1484 status_box->active_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(status_box->dropdown_store), path); |
1484 status_box->active_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(status_box->dropdown_store), path); |
| 1485 |
1485 |
| 1486 pidgin_status_box_popdown (status_box); |
1486 pidgin_status_box_popdown (status_box); |
| 1487 gtk_gaim_status_box_changed(status_box); |
1487 pidgin_status_box_changed(status_box); |
| 1488 } |
1488 } |
| 1489 |
1489 |
| 1490 static gboolean |
1490 static gboolean |
| 1491 treeview_button_release_cb(GtkWidget *widget, GdkEventButton *event, GtkGaimStatusBox *status_box) |
1491 treeview_button_release_cb(GtkWidget *widget, GdkEventButton *event, PidginStatusBox *status_box) |
| 1492 { |
1492 { |
| 1493 GtkTreePath *path = NULL; |
1493 GtkTreePath *path = NULL; |
| 1494 int ret; |
1494 int ret; |
| 1495 GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event); |
1495 GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event); |
| 1496 |
1496 |
| 1725 gaim_prefs_connect_callback(status_box, "/gaim/gtk/accounts/buddyicon", |
1725 gaim_prefs_connect_callback(status_box, "/gaim/gtk/accounts/buddyicon", |
| 1726 update_buddyicon_cb, status_box); |
1726 update_buddyicon_cb, status_box); |
| 1727 } |
1727 } |
| 1728 |
1728 |
| 1729 static void |
1729 static void |
| 1730 gtk_gaim_status_box_size_request(GtkWidget *widget, |
1730 pidgin_status_box_size_request(GtkWidget *widget, |
| 1731 GtkRequisition *requisition) |
1731 GtkRequisition *requisition) |
| 1732 { |
1732 { |
| 1733 GtkRequisition box_req; |
1733 GtkRequisition box_req; |
| 1734 gint border_width = GTK_CONTAINER (widget)->border_width; |
1734 gint border_width = GTK_CONTAINER (widget)->border_width; |
| 1735 |
1735 |
| 1736 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->toggle_button, requisition); |
1736 gtk_widget_size_request(PIDGIN_STATUS_BOX(widget)->toggle_button, requisition); |
| 1737 |
1737 |
| 1738 /* Make this icon the same size as other buddy icons in the list; unless it already wants to be bigger */ |
1738 /* Make this icon the same size as other buddy icons in the list; unless it already wants to be bigger */ |
| 1739 requisition->height = MAX(requisition->height, 34); |
1739 requisition->height = MAX(requisition->height, 34); |
| 1740 requisition->height += border_width * 2; |
1740 requisition->height += border_width * 2; |
| 1741 |
1741 |
| 1742 /* If the gtkimhtml is visible, then add some additional padding */ |
1742 /* If the gtkimhtml is visible, then add some additional padding */ |
| 1743 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); |
1743 gtk_widget_size_request(PIDGIN_STATUS_BOX(widget)->vbox, &box_req); |
| 1744 if (box_req.height > 1) |
1744 if (box_req.height > 1) |
| 1745 requisition->height += box_req.height + border_width * 2; |
1745 requisition->height += box_req.height + border_width * 2; |
| 1746 |
1746 |
| 1747 requisition->width = 1; |
1747 requisition->width = 1; |
| 1748 } |
1748 } |
| 1786 } |
1786 } |
| 1787 } |
1787 } |
| 1788 } |
1788 } |
| 1789 |
1789 |
| 1790 static void |
1790 static void |
| 1791 gtk_gaim_status_box_size_allocate(GtkWidget *widget, |
1791 pidgin_status_box_size_allocate(GtkWidget *widget, |
| 1792 GtkAllocation *allocation) |
1792 GtkAllocation *allocation) |
| 1793 { |
1793 { |
| 1794 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
1794 PidginStatusBox *status_box = PIDGIN_STATUS_BOX(widget); |
| 1795 GtkRequisition req = {0,0}; |
1795 GtkRequisition req = {0,0}; |
| 1796 GtkAllocation parent_alc, box_alc, icon_alc; |
1796 GtkAllocation parent_alc, box_alc, icon_alc; |
| 1797 gint border_width = GTK_CONTAINER (widget)->border_width; |
1797 gint border_width = GTK_CONTAINER (widget)->border_width; |
| 1798 |
1798 |
| 1799 gtk_widget_size_request(status_box->toggle_button, &req); |
1799 gtk_widget_size_request(status_box->toggle_button, &req); |
| 1832 icon_alc.y += 1; |
1832 icon_alc.y += 1; |
| 1833 |
1833 |
| 1834 if (status_box->icon_size != icon_alc.height) |
1834 if (status_box->icon_size != icon_alc.height) |
| 1835 { |
1835 { |
| 1836 status_box->icon_size = icon_alc.height; |
1836 status_box->icon_size = icon_alc.height; |
| 1837 gtk_gaim_status_box_redisplay_buddy_icon(status_box); |
1837 pidgin_status_box_redisplay_buddy_icon(status_box); |
| 1838 } |
1838 } |
| 1839 gtk_widget_size_allocate(status_box->icon_box, &icon_alc); |
1839 gtk_widget_size_allocate(status_box->icon_box, &icon_alc); |
| 1840 } |
1840 } |
| 1841 gtk_widget_size_allocate(status_box->toggle_button, &parent_alc); |
1841 gtk_widget_size_allocate(status_box->toggle_button, &parent_alc); |
| 1842 widget->allocation = *allocation; |
1842 widget->allocation = *allocation; |
| 1843 } |
1843 } |
| 1844 |
1844 |
| 1845 static gboolean |
1845 static gboolean |
| 1846 gtk_gaim_status_box_expose_event(GtkWidget *widget, |
1846 pidgin_status_box_expose_event(GtkWidget *widget, |
| 1847 GdkEventExpose *event) |
1847 GdkEventExpose *event) |
| 1848 { |
1848 { |
| 1849 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
1849 PidginStatusBox *status_box = PIDGIN_STATUS_BOX(widget); |
| 1850 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->vbox, event); |
1850 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->vbox, event); |
| 1851 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->toggle_button, event); |
1851 gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->toggle_button, event); |
| 1852 if (status_box->icon_box && status_box->icon_opaque) { |
1852 if (status_box->icon_box && status_box->icon_opaque) { |
| 1853 gtk_paint_box(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, |
1853 gtk_paint_box(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, |
| 1854 status_box->icon_box, "button", status_box->icon_box->allocation.x-1, status_box->icon_box->allocation.y-1, |
1854 status_box->icon_box, "button", status_box->icon_box->allocation.x-1, status_box->icon_box->allocation.y-1, |
| 1856 } |
1856 } |
| 1857 return FALSE; |
1857 return FALSE; |
| 1858 } |
1858 } |
| 1859 |
1859 |
| 1860 static void |
1860 static void |
| 1861 gtk_gaim_status_box_forall(GtkContainer *container, |
1861 pidgin_status_box_forall(GtkContainer *container, |
| 1862 gboolean include_internals, |
1862 gboolean include_internals, |
| 1863 GtkCallback callback, |
1863 GtkCallback callback, |
| 1864 gpointer callback_data) |
1864 gpointer callback_data) |
| 1865 { |
1865 { |
| 1866 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (container); |
1866 PidginStatusBox *status_box = PIDGIN_STATUS_BOX (container); |
| 1867 |
1867 |
| 1868 if (include_internals) |
1868 if (include_internals) |
| 1869 { |
1869 { |
| 1870 (* callback) (status_box->vbox, callback_data); |
1870 (* callback) (status_box->vbox, callback_data); |
| 1871 (* callback) (status_box->toggle_button, callback_data); |
1871 (* callback) (status_box->toggle_button, callback_data); |
| 1874 (* callback) (status_box->icon_box, callback_data); |
1874 (* callback) (status_box->icon_box, callback_data); |
| 1875 } |
1875 } |
| 1876 } |
1876 } |
| 1877 |
1877 |
| 1878 GtkWidget * |
1878 GtkWidget * |
| 1879 gtk_gaim_status_box_new() |
1879 pidgin_status_box_new() |
| 1880 { |
1880 { |
| 1881 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", NULL, |
1881 return g_object_new(PIDGIN_TYPE_STATUS_BOX, "account", NULL, |
| 1882 "iconsel", TRUE, NULL); |
1882 "iconsel", TRUE, NULL); |
| 1883 } |
1883 } |
| 1884 |
1884 |
| 1885 GtkWidget * |
1885 GtkWidget * |
| 1886 gtk_gaim_status_box_new_with_account(GaimAccount *account) |
1886 pidgin_status_box_new_with_account(GaimAccount *account) |
| 1887 { |
1887 { |
| 1888 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", account, |
1888 return g_object_new(PIDGIN_TYPE_STATUS_BOX, "account", account, |
| 1889 "iconsel", TRUE, NULL); |
1889 "iconsel", TRUE, NULL); |
| 1890 } |
1890 } |
| 1891 |
1891 |
| 1892 /** |
1892 /** |
| 1893 * Add a row to the dropdown menu. |
1893 * Add a row to the dropdown menu. |
| 1894 * |
1894 * |
| 1895 * @param status_box The status box itself. |
1895 * @param status_box The status box itself. |
| 1896 * @param type A GtkGaimStatusBoxItemType. |
1896 * @param type A PidginStatusBoxItemType. |
| 1897 * @param pixbuf The icon to associate with this row in the menu. |
1897 * @param pixbuf The icon to associate with this row in the menu. |
| 1898 * @param title The title of this item. For the primitive entries, |
1898 * @param title The title of this item. For the primitive entries, |
| 1899 * this is something like "Available" or "Away." For |
1899 * this is something like "Available" or "Away." For |
| 1900 * the saved statuses, this is something like |
1900 * the saved statuses, this is something like |
| 1901 * "My favorite away message!" This should be |
1901 * "My favorite away message!" This should be |
| 1951 -1); |
1951 -1); |
| 1952 g_free(text); |
1952 g_free(text); |
| 1953 } |
1953 } |
| 1954 |
1954 |
| 1955 void |
1955 void |
| 1956 gtk_gaim_status_box_add_separator(GtkGaimStatusBox *status_box) |
1956 pidgin_status_box_add_separator(PidginStatusBox *status_box) |
| 1957 { |
1957 { |
| 1958 /* Don't do anything unless GTK actually supports |
1958 /* Don't do anything unless GTK actually supports |
| 1959 * gtk_combo_box_set_row_separator_func */ |
1959 * gtk_combo_box_set_row_separator_func */ |
| 1960 #if GTK_CHECK_VERSION(2,6,0) |
1960 #if GTK_CHECK_VERSION(2,6,0) |
| 1961 GtkTreeIter iter; |
1961 GtkTreeIter iter; |
| 1962 |
1962 |
| 1963 gtk_list_store_append(status_box->dropdown_store, &iter); |
1963 gtk_list_store_append(status_box->dropdown_store, &iter); |
| 1964 gtk_list_store_set(status_box->dropdown_store, &iter, |
1964 gtk_list_store_set(status_box->dropdown_store, &iter, |
| 1965 TYPE_COLUMN, GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR, |
1965 TYPE_COLUMN, PIDGIN_STATUS_BOX_TYPE_SEPARATOR, |
| 1966 -1); |
1966 -1); |
| 1967 #endif |
1967 #endif |
| 1968 } |
1968 } |
| 1969 |
1969 |
| 1970 void |
1970 void |
| 1971 gtk_gaim_status_box_set_network_available(GtkGaimStatusBox *status_box, gboolean available) |
1971 pidgin_status_box_set_network_available(PidginStatusBox *status_box, gboolean available) |
| 1972 { |
1972 { |
| 1973 if (!status_box) |
1973 if (!status_box) |
| 1974 return; |
1974 return; |
| 1975 status_box->network_available = available; |
1975 status_box->network_available = available; |
| 1976 gtk_gaim_status_box_refresh(status_box); |
1976 pidgin_status_box_refresh(status_box); |
| 1977 } |
1977 } |
| 1978 |
1978 |
| 1979 void |
1979 void |
| 1980 gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting) |
1980 pidgin_status_box_set_connecting(PidginStatusBox *status_box, gboolean connecting) |
| 1981 { |
1981 { |
| 1982 if (!status_box) |
1982 if (!status_box) |
| 1983 return; |
1983 return; |
| 1984 status_box->connecting = connecting; |
1984 status_box->connecting = connecting; |
| 1985 gtk_gaim_status_box_refresh(status_box); |
1985 pidgin_status_box_refresh(status_box); |
| 1986 } |
1986 } |
| 1987 |
1987 |
| 1988 static void |
1988 static void |
| 1989 gtk_gaim_status_box_redisplay_buddy_icon(GtkGaimStatusBox *status_box) |
1989 pidgin_status_box_redisplay_buddy_icon(PidginStatusBox *status_box) |
| 1990 { |
1990 { |
| 1991 |
1991 |
| 1992 /* This is sometimes called before the box is shown, and we will not have a size */ |
1992 /* This is sometimes called before the box is shown, and we will not have a size */ |
| 1993 if (status_box->icon_size <= 0) |
1993 if (status_box->icon_size <= 0) |
| 1994 return; |
1994 return; |
| 2023 gtk_widget_queue_resize(GTK_WIDGET(status_box)); |
2023 gtk_widget_queue_resize(GTK_WIDGET(status_box)); |
| 2024 } |
2024 } |
| 2025 } |
2025 } |
| 2026 |
2026 |
| 2027 void |
2027 void |
| 2028 gtk_gaim_status_box_set_buddy_icon(GtkGaimStatusBox *status_box, const char *filename) |
2028 pidgin_status_box_set_buddy_icon(PidginStatusBox *status_box, const char *filename) |
| 2029 { |
2029 { |
| 2030 g_free(status_box->buddy_icon_path); |
2030 g_free(status_box->buddy_icon_path); |
| 2031 status_box->buddy_icon_path = g_strdup(filename); |
2031 status_box->buddy_icon_path = g_strdup(filename); |
| 2032 |
2032 |
| 2033 gtk_gaim_status_box_redisplay_buddy_icon(status_box); |
2033 pidgin_status_box_redisplay_buddy_icon(status_box); |
| 2034 } |
2034 } |
| 2035 |
2035 |
| 2036 const char* |
2036 const char* |
| 2037 gtk_gaim_status_box_get_buddy_icon(GtkGaimStatusBox *box) |
2037 pidgin_status_box_get_buddy_icon(PidginStatusBox *box) |
| 2038 { |
2038 { |
| 2039 return box->buddy_icon_path; |
2039 return box->buddy_icon_path; |
| 2040 } |
2040 } |
| 2041 |
2041 |
| 2042 void |
2042 void |
| 2043 gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box) |
2043 pidgin_status_box_pulse_connecting(PidginStatusBox *status_box) |
| 2044 { |
2044 { |
| 2045 if (!status_box) |
2045 if (!status_box) |
| 2046 return; |
2046 return; |
| 2047 if (status_box->connecting_index == 3) |
2047 if (status_box->connecting_index == 3) |
| 2048 status_box->connecting_index = 0; |
2048 status_box->connecting_index = 0; |
| 2049 else |
2049 else |
| 2050 status_box->connecting_index++; |
2050 status_box->connecting_index++; |
| 2051 gtk_gaim_status_box_refresh(status_box); |
2051 pidgin_status_box_refresh(status_box); |
| 2052 } |
2052 } |
| 2053 |
2053 |
| 2054 static void |
2054 static void |
| 2055 gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box) |
2055 pidgin_status_box_pulse_typing(PidginStatusBox *status_box) |
| 2056 { |
2056 { |
| 2057 if (status_box->typing_index == 3) |
2057 if (status_box->typing_index == 3) |
| 2058 status_box->typing_index = 0; |
2058 status_box->typing_index = 0; |
| 2059 else |
2059 else |
| 2060 status_box->typing_index++; |
2060 status_box->typing_index++; |
| 2061 gtk_gaim_status_box_refresh(status_box); |
2061 pidgin_status_box_refresh(status_box); |
| 2062 } |
2062 } |
| 2063 |
2063 |
| 2064 static gboolean |
2064 static gboolean |
| 2065 message_changed(const char *one, const char *two) |
2065 message_changed(const char *one, const char *two) |
| 2066 { |
2066 { |
| 2101 * Popular statuses are |
2101 * Popular statuses are |
| 2102 * activated elsewhere, and we update the status_box |
2102 * activated elsewhere, and we update the status_box |
| 2103 * accordingly by connecting to the savedstatus-changed |
2103 * accordingly by connecting to the savedstatus-changed |
| 2104 * signal and then calling status_menu_refresh_iter() |
2104 * signal and then calling status_menu_refresh_iter() |
| 2105 */ |
2105 */ |
| 2106 if (type != GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE) |
2106 if (type != PIDGIN_STATUS_BOX_TYPE_PRIMITIVE) |
| 2107 return; |
2107 return; |
| 2108 |
2108 |
| 2109 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
2109 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
| 2110 TITLE_COLUMN, &title, -1); |
2110 TITLE_COLUMN, &title, -1); |
| 2111 |
2111 |
| 2112 message = gtk_gaim_status_box_get_message(status_box); |
2112 message = pidgin_status_box_get_message(status_box); |
| 2113 if (!message || !*message) |
2113 if (!message || !*message) |
| 2114 { |
2114 { |
| 2115 gtk_widget_hide_all(status_box->vbox); |
2115 gtk_widget_hide_all(status_box->vbox); |
| 2116 status_box->imhtml_visible = FALSE; |
2116 status_box->imhtml_visible = FALSE; |
| 2117 if (message != NULL) |
2117 if (message != NULL) |
| 2347 g_source_remove(status_box->typing); |
2347 g_source_remove(status_box->typing); |
| 2348 status_box->typing = 0; |
2348 status_box->typing = 0; |
| 2349 |
2349 |
| 2350 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
2350 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
| 2351 { |
2351 { |
| 2352 if (type == GTK_GAIM_STATUS_BOX_TYPE_POPULAR) |
2352 if (type == PIDGIN_STATUS_BOX_TYPE_POPULAR) |
| 2353 { |
2353 { |
| 2354 GaimSavedStatus *saved; |
2354 GaimSavedStatus *saved; |
| 2355 saved = gaim_savedstatus_find_by_creation_time(GPOINTER_TO_INT(data)); |
2355 saved = gaim_savedstatus_find_by_creation_time(GPOINTER_TO_INT(data)); |
| 2356 g_return_if_fail(saved != NULL); |
2356 g_return_if_fail(saved != NULL); |
| 2357 gaim_savedstatus_activate(saved); |
2357 gaim_savedstatus_activate(saved); |
| 2358 return; |
2358 return; |
| 2359 } |
2359 } |
| 2360 |
2360 |
| 2361 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM) |
2361 if (type == PIDGIN_STATUS_BOX_TYPE_CUSTOM) |
| 2362 { |
2362 { |
| 2363 GaimSavedStatus *saved_status; |
2363 GaimSavedStatus *saved_status; |
| 2364 saved_status = gaim_savedstatus_get_current(); |
2364 saved_status = gaim_savedstatus_get_current(); |
| 2365 pidgin_status_editor_show(FALSE, |
2365 pidgin_status_editor_show(FALSE, |
| 2366 gaim_savedstatus_is_transient(saved_status) |
2366 gaim_savedstatus_is_transient(saved_status) |
| 2367 ? saved_status : NULL); |
2367 ? saved_status : NULL); |
| 2368 status_menu_refresh_iter(status_box); |
2368 status_menu_refresh_iter(status_box); |
| 2369 return; |
2369 return; |
| 2370 } |
2370 } |
| 2371 |
2371 |
| 2372 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED) |
2372 if (type == PIDGIN_STATUS_BOX_TYPE_SAVED) |
| 2373 { |
2373 { |
| 2374 pidgin_status_window_show(); |
2374 pidgin_status_window_show(); |
| 2375 status_menu_refresh_iter(status_box); |
2375 status_menu_refresh_iter(status_box); |
| 2376 return; |
2376 return; |
| 2377 } |
2377 } |
| 2449 return index; |
2449 return index; |
| 2450 } |
2450 } |
| 2451 |
2451 |
| 2452 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data) |
2452 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data) |
| 2453 { |
2453 { |
| 2454 GtkGaimStatusBox *status_box = (GtkGaimStatusBox*)data; |
2454 PidginStatusBox *status_box = (PidginStatusBox*)data; |
| 2455 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
2455 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box))) |
| 2456 { |
2456 { |
| 2457 if (status_box->typing != 0) { |
2457 if (status_box->typing != 0) { |
| 2458 gtk_gaim_status_box_pulse_typing(status_box); |
2458 pidgin_status_box_pulse_typing(status_box); |
| 2459 g_source_remove(status_box->typing); |
2459 g_source_remove(status_box->typing); |
| 2460 } |
2460 } |
| 2461 status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); |
2461 status_box->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, status_box); |
| 2462 } |
2462 } |
| 2463 gtk_gaim_status_box_refresh(status_box); |
2463 pidgin_status_box_refresh(status_box); |
| 2464 } |
2464 } |
| 2465 |
2465 |
| 2466 static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data) |
2466 static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data) |
| 2467 { |
2467 { |
| 2468 imhtml_changed_cb(NULL, data); |
2468 imhtml_changed_cb(NULL, data); |
| 2469 } |
2469 } |
| 2470 |
2470 |
| 2471 char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box) |
2471 char *pidgin_status_box_get_message(PidginStatusBox *status_box) |
| 2472 { |
2472 { |
| 2473 if (status_box->imhtml_visible) |
2473 if (status_box->imhtml_visible) |
| 2474 return gtk_imhtml_get_markup(GTK_IMHTML(status_box->imhtml)); |
2474 return gtk_imhtml_get_markup(GTK_IMHTML(status_box->imhtml)); |
| 2475 else |
2475 else |
| 2476 return NULL; |
2476 return NULL; |