| 81 static void gtk_gaim_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); |
81 static void gtk_gaim_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); |
| 82 |
82 |
| 83 static void do_colorshift (GdkPixbuf *dest, GdkPixbuf *src, int shift); |
83 static void do_colorshift (GdkPixbuf *dest, GdkPixbuf *src, int shift); |
| 84 static void icon_choose_cb(const char *filename, gpointer data); |
84 static void icon_choose_cb(const char *filename, gpointer data); |
| 85 |
85 |
| |
86 static void (*combo_box_size_request)(GtkWidget *widget, GtkRequisition *requisition); |
| |
87 static void (*combo_box_size_allocate)(GtkWidget *widget, GtkAllocation *allocation); |
| |
88 static void (*combo_box_forall) (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); |
| |
89 |
| 86 enum { |
90 enum { |
| 87 /** A GtkGaimStatusBoxItemType */ |
91 /** A GtkGaimStatusBoxItemType */ |
| 88 TYPE_COLUMN, |
92 TYPE_COLUMN, |
| 89 |
93 |
| 90 /** |
94 /** |
| 420 |
424 |
| 421 static void |
425 static void |
| 422 gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass) |
426 gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass) |
| 423 { |
427 { |
| 424 GObjectClass *object_class; |
428 GObjectClass *object_class; |
| |
429 GtkComboBoxClass *combo_class; |
| 425 GtkWidgetClass *widget_class; |
430 GtkWidgetClass *widget_class; |
| 426 GtkContainerClass *container_class = (GtkContainerClass*)klass; |
431 GtkContainerClass *container_class = (GtkContainerClass*)klass; |
| 427 |
432 |
| 428 parent_class = g_type_class_peek_parent(klass); |
433 parent_class = g_type_class_peek_parent(klass); |
| 429 |
434 |
| |
435 combo_class = (GtkComboBoxClass*)klass; |
| |
436 combo_class->changed = gtk_gaim_status_box_changed; |
| |
437 |
| 430 widget_class = (GtkWidgetClass*)klass; |
438 widget_class = (GtkWidgetClass*)klass; |
| |
439 combo_box_size_request = widget_class->size_request; |
| 431 widget_class->size_request = gtk_gaim_status_box_size_request; |
440 widget_class->size_request = gtk_gaim_status_box_size_request; |
| |
441 combo_box_size_allocate = widget_class->size_allocate; |
| 432 widget_class->size_allocate = gtk_gaim_status_box_size_allocate; |
442 widget_class->size_allocate = gtk_gaim_status_box_size_allocate; |
| 433 widget_class->expose_event = gtk_gaim_status_box_expose_event; |
443 widget_class->expose_event = gtk_gaim_status_box_expose_event; |
| 434 |
444 |
| |
445 combo_box_forall = container_class->forall; |
| 435 container_class->forall = gtk_gaim_status_box_forall; |
446 container_class->forall = gtk_gaim_status_box_forall; |
| 436 container_class->remove = NULL; |
447 container_class->remove = NULL; |
| 437 |
448 |
| 438 object_class = (GObjectClass *)klass; |
449 object_class = (GObjectClass *)klass; |
| 439 |
450 |
| 505 GtkTreeIter iter; |
516 GtkTreeIter iter; |
| 506 GtkGaimStatusBoxItemType type; |
517 GtkGaimStatusBoxItemType type; |
| 507 gpointer data; |
518 gpointer data; |
| 508 |
519 |
| 509 /* Primary (get the status selected in the dropdown) */ |
520 /* Primary (get the status selected in the dropdown) */ |
| 510 // gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); |
521 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); |
| 511 // gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
522 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, |
| 512 // TYPE_COLUMN, &type, |
523 TYPE_COLUMN, &type, |
| 513 // DATA_COLUMN, &data, |
524 DATA_COLUMN, &data, |
| 514 // -1); |
525 -1); |
| 515 // if (type == GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE) |
526 if (type == GTK_GAIM_STATUS_BOX_TYPE_PRIMITIVE) |
| 516 // primary = g_strdup(gaim_primitive_get_name_from_type(GPOINTER_TO_INT(data))); |
527 primary = g_strdup(gaim_primitive_get_name_from_type(GPOINTER_TO_INT(data))); |
| 517 // else |
528 else |
| 518 // /* This should never happen, but just in case... */ |
529 /* This should never happen, but just in case... */ |
| 519 // primary = g_strdup("New status"); |
530 primary = g_strdup("New status"); |
| 520 primary = g_strdup("Available"); |
|
| 521 } |
531 } |
| 522 else if (account_status) |
532 else if (account_status) |
| 523 primary = g_strdup(gaim_status_get_name(gaim_account_get_active_status(acct))); |
533 primary = g_strdup(gaim_status_get_name(gaim_account_get_active_status(acct))); |
| 524 else if (gaim_savedstatus_is_transient(saved_status)) |
534 else if (gaim_savedstatus_is_transient(saved_status)) |
| 525 primary = g_strdup(gaim_primitive_get_name_from_type(gaim_savedstatus_get_type(saved_status))); |
535 primary = g_strdup(gaim_primitive_get_name_from_type(gaim_savedstatus_get_type(saved_status))); |
| 681 ((primitive == GAIM_STATUS_AVAILABLE) || (primitive == GAIM_STATUS_AWAY) || |
691 ((primitive == GAIM_STATUS_AVAILABLE) || (primitive == GAIM_STATUS_AWAY) || |
| 682 (primitive == GAIM_STATUS_INVISIBLE) || (primitive == GAIM_STATUS_OFFLINE)) && |
692 (primitive == GAIM_STATUS_INVISIBLE) || (primitive == GAIM_STATUS_OFFLINE)) && |
| 683 (!gaim_savedstatus_has_substatuses(saved_status))) |
693 (!gaim_savedstatus_has_substatuses(saved_status))) |
| 684 { |
694 { |
| 685 index = get_statusbox_index(status_box, saved_status); |
695 index = get_statusbox_index(status_box, saved_status); |
| 686 // gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), index); |
696 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), index); |
| 687 } |
697 } |
| 688 else |
698 else |
| 689 { |
699 { |
| 690 GtkTreeIter iter; |
700 GtkTreeIter iter; |
| 691 GtkGaimStatusBoxItemType type; |
701 GtkGaimStatusBoxItemType type; |
| 692 gpointer data; |
702 gpointer data; |
| 693 |
703 |
| 694 /* Unset the active item */ |
704 /* Unset the active item */ |
| 695 // gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), -1); |
705 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), -1); |
| 696 |
706 |
| 697 /* If this saved status is in the list store, then set it as the active item */ |
707 /* If this saved status is in the list store, then set it as the active item */ |
| 698 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(status_box->dropdown_store), &iter)) |
708 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(status_box->dropdown_store), &iter)) |
| 699 { |
709 { |
| 700 do |
710 do |
| 718 |
728 |
| 719 if (!gaim_savedstatus_has_substatuses(saved_status) |
729 if (!gaim_savedstatus_has_substatuses(saved_status) |
| 720 || !strcmp(name, acct_status_name)) |
730 || !strcmp(name, acct_status_name)) |
| 721 { |
731 { |
| 722 /* Found! */ |
732 /* Found! */ |
| 723 // gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter); |
733 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter); |
| 724 g_free(name); |
734 g_free(name); |
| 725 break; |
735 break; |
| 726 } |
736 } |
| 727 g_free(name); |
737 g_free(name); |
| 728 } |
738 } |
| 729 else if ((type == GTK_GAIM_STATUS_BOX_TYPE_POPULAR) && |
739 else if ((type == GTK_GAIM_STATUS_BOX_TYPE_POPULAR) && |
| 730 (GPOINTER_TO_INT(data) == gaim_savedstatus_get_creation_time(saved_status))) |
740 (GPOINTER_TO_INT(data) == gaim_savedstatus_get_creation_time(saved_status))) |
| 731 { |
741 { |
| 732 /* Found! */ |
742 /* Found! */ |
| 733 // gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter); |
743 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(status_box), &iter); |
| 734 break; |
744 break; |
| 735 } |
745 } |
| 736 } |
746 } |
| 737 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(status_box->dropdown_store), &iter)); |
747 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(status_box->dropdown_store), &iter)); |
| 738 } |
748 } |
| 931 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); |
941 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); |
| 932 else |
942 else |
| 933 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL); |
943 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS_SMALL); |
| 934 |
944 |
| 935 /* Unset the model while clearing it */ |
945 /* Unset the model while clearing it */ |
| 936 // gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), NULL); |
946 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), NULL); |
| 937 gtk_list_store_clear(status_box->dropdown_store); |
947 gtk_list_store_clear(status_box->dropdown_store); |
| 938 /* Don't set the model until the new statuses have been added to the box. |
948 /* Don't set the model until the new statuses have been added to the box. |
| 939 * What is presumably a bug in Gtk < 2.4 causes things to get all confused |
949 * What is presumably a bug in Gtk < 2.4 causes things to get all confused |
| 940 * if we do this here. */ |
950 * if we do this here. */ |
| 941 /* gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); */ |
951 /* gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); */ |
| 973 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box)); |
983 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box)); |
| 974 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("New..."), NULL, NULL); |
984 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("New..."), NULL, NULL); |
| 975 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL, NULL); |
985 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL, NULL); |
| 976 if (pixbuf) g_object_unref(G_OBJECT(pixbuf)); |
986 if (pixbuf) g_object_unref(G_OBJECT(pixbuf)); |
| 977 |
987 |
| 978 // gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
988 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
| 979 status_menu_refresh_iter(status_box); |
989 status_menu_refresh_iter(status_box); |
| 980 |
990 |
| 981 } else { |
991 } else { |
| 982 add_account_statuses(status_box, status_box->account, show_buddy_icons); |
992 add_account_statuses(status_box, status_box->account, show_buddy_icons); |
| 983 update_to_reflect_account_status(status_box, status_box->account, |
993 update_to_reflect_account_status(status_box, status_box->account, |
| 1260 status_box->vsep = gtk_vseparator_new(); |
1270 status_box->vsep = gtk_vseparator_new(); |
| 1261 status_box->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); |
1271 status_box->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); |
| 1262 |
1272 |
| 1263 status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
1273 status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
| 1264 status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
1274 status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
| 1265 // gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
1275 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); |
| 1266 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); |
1276 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); |
| 1267 // gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0); |
1277 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0); |
| 1268 gtk_list_store_append(status_box->store, &(status_box->iter)); |
1278 gtk_list_store_append(status_box->store, &(status_box->iter)); |
| 1269 |
1279 |
| 1270 gtk_container_add(GTK_CONTAINER(status_box->toggle_button), status_box->hbox); |
1280 gtk_container_add(GTK_CONTAINER(status_box->toggle_button), status_box->hbox); |
| 1271 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->cell_view, TRUE, TRUE, 0); |
1281 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->cell_view, TRUE, TRUE, 0); |
| 1272 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->vsep, FALSE, FALSE, 0); |
1282 gtk_box_pack_start(GTK_BOX(status_box->hbox), status_box->vsep, FALSE, FALSE, 0); |
| 1276 gtk_button_set_focus_on_click(GTK_BUTTON(status_box->toggle_button), FALSE); |
1286 gtk_button_set_focus_on_click(GTK_BUTTON(status_box->toggle_button), FALSE); |
| 1277 #endif |
1287 #endif |
| 1278 |
1288 |
| 1279 text_rend = gtk_cell_renderer_text_new(); |
1289 text_rend = gtk_cell_renderer_text_new(); |
| 1280 icon_rend = gtk_cell_renderer_pixbuf_new(); |
1290 icon_rend = gtk_cell_renderer_pixbuf_new(); |
| 1281 // gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), icon_rend, FALSE); |
1291 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), icon_rend, FALSE); |
| 1282 // gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE); |
1292 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE); |
| 1283 // gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL); |
1293 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL); |
| 1284 // gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL); |
1294 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL); |
| 1285 #if GTK_CHECK_VERSION(2, 6, 0) |
1295 #if GTK_CHECK_VERSION(2, 6, 0) |
| 1286 g_object_set(text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
1296 g_object_set(text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
| 1287 #endif |
1297 #endif |
| 1288 |
1298 |
| 1289 status_box->icon_rend = gtk_cell_renderer_pixbuf_new(); |
1299 status_box->icon_rend = gtk_cell_renderer_pixbuf_new(); |
| 1290 status_box->text_rend = gtk_cell_renderer_text_new(); |
1300 status_box->text_rend = gtk_cell_renderer_text_new(); |
| 1291 // gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); |
1301 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); |
| 1292 // gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); |
1302 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); |
| 1293 // gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); |
1303 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); |
| 1294 // gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); |
1304 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); |
| 1295 #if GTK_CHECK_VERSION(2, 6, 0) |
1305 #if GTK_CHECK_VERSION(2, 6, 0) |
| 1296 g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
1306 g_object_set(status_box->text_rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
| 1297 #endif |
1307 #endif |
| 1298 |
1308 |
| 1299 status_box->vbox = gtk_vbox_new(0, FALSE); |
1309 status_box->vbox = gtk_vbox_new(0, FALSE); |
| 1329 g_signal_connect(G_OBJECT(status_box), "scroll_event", G_CALLBACK(combo_box_scroll_event_cb), NULL); |
1339 g_signal_connect(G_OBJECT(status_box), "scroll_event", G_CALLBACK(combo_box_scroll_event_cb), NULL); |
| 1330 g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event", |
1340 g_signal_connect(G_OBJECT(status_box->imhtml), "scroll_event", |
| 1331 G_CALLBACK(imhtml_scroll_event_cb), status_box->imhtml); |
1341 G_CALLBACK(imhtml_scroll_event_cb), status_box->imhtml); |
| 1332 |
1342 |
| 1333 #if GTK_CHECK_VERSION(2,6,0) |
1343 #if GTK_CHECK_VERSION(2,6,0) |
| 1334 // gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(status_box), dropdown_store_row_separator_func, NULL, NULL); |
1344 gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(status_box), dropdown_store_row_separator_func, NULL, NULL); |
| 1335 #endif |
1345 #endif |
| 1336 |
1346 |
| 1337 status_box->token_status_account = check_active_accounts_for_identical_statuses(); |
1347 status_box->token_status_account = check_active_accounts_for_identical_statuses(); |
| 1338 |
1348 |
| 1339 cache_pixbufs(status_box); |
1349 cache_pixbufs(status_box); |
| 1364 static void |
1374 static void |
| 1365 gtk_gaim_status_box_size_request(GtkWidget *widget, |
1375 gtk_gaim_status_box_size_request(GtkWidget *widget, |
| 1366 GtkRequisition *requisition) |
1376 GtkRequisition *requisition) |
| 1367 { |
1377 { |
| 1368 GtkRequisition box_req; |
1378 GtkRequisition box_req; |
| 1369 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->toggle_button, requisition); |
1379 combo_box_size_request(widget, requisition); |
| 1370 requisition->height += 3; |
1380 requisition->height += 3; |
| 1371 |
1381 |
| 1372 /* If the gtkimhtml is visible, then add some additional padding */ |
1382 /* If the gtkimhtml is visible, then add some additional padding */ |
| 1373 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); |
1383 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); |
| 1374 if (box_req.height > 1) |
1384 if (box_req.height > 1) |
| 1426 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
1436 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget); |
| 1427 GtkRequisition req = {0,0}; |
1437 GtkRequisition req = {0,0}; |
| 1428 GtkAllocation parent_alc, box_alc, icon_alc; |
1438 GtkAllocation parent_alc, box_alc, icon_alc; |
| 1429 gint border_width = GTK_CONTAINER (widget)->border_width; |
1439 gint border_width = GTK_CONTAINER (widget)->border_width; |
| 1430 |
1440 |
| 1431 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->toggle_button, &req); |
1441 combo_box_size_request(widget, &req); |
| 1432 |
1442 |
| 1433 box_alc = *allocation; |
1443 box_alc = *allocation; |
| 1434 |
1444 |
| 1435 box_alc.width -= (border_width * 2); |
1445 box_alc.width -= (border_width * 2); |
| 1436 box_alc.height = MAX(1, ((allocation->height - req.height) - (border_width*2))); |
1446 box_alc.height = MAX(1, ((allocation->height - req.height) - (border_width*2))); |