pidgin/gtksavedstatuses.c

changeset 16575
c7f80fead80f
parent 16490
68c22924d66b
child 16697
aaff39c4a5af
equal deleted inserted replaced
16529:1d0da9270ff9 16575:c7f80fead80f
328 title = g_strdup_printf(_("Are you sure you want to delete %s?"), 328 title = g_strdup_printf(_("Are you sure you want to delete %s?"),
329 (const gchar *)sel_titles->data); 329 (const gchar *)sel_titles->data);
330 else 330 else
331 title = g_strdup(_("Are you sure you want to delete the selected saved statuses?")); 331 title = g_strdup(_("Are you sure you want to delete the selected saved statuses?"));
332 332
333 purple_request_action(dialog, NULL, title, 333 purple_request_action(dialog, NULL, title, NULL, 0,
334 NULL, 0, sel_titles, 2, 334 NULL, NULL, NULL,
335 sel_titles, 2,
335 _("Delete"), status_window_delete_confirm_cb, 336 _("Delete"), status_window_delete_confirm_cb,
336 _("Cancel"), status_window_delete_cancel_cb); 337 _("Cancel"), status_window_delete_cancel_cb);
337 338
338 g_free(title); 339 g_free(title);
339 } 340 }
1583 SS_MENU_ICON_COLUMN, 1584 SS_MENU_ICON_COLUMN,
1584 1585
1585 /** The text displayed on the status box. This column is visible. */ 1586 /** The text displayed on the status box. This column is visible. */
1586 SS_MENU_TEXT_COLUMN, 1587 SS_MENU_TEXT_COLUMN,
1587 1588
1588 /* 1589 /**
1589 * This value depends on SS_MENU_TYPE_COLUMN. For _SAVEDSTATUS types, 1590 * This value depends on SS_MENU_TYPE_COLUMN. For _SAVEDSTATUS types,
1590 * this is the creation time. For _PRIMITIVE types, 1591 * this is the creation time. For _PRIMITIVE types,
1591 * this is the PurpleStatusPrimitive. 1592 * this is the PurpleStatusPrimitive.
1592 */ 1593 */
1593 SS_MENU_DATA_COLUMN, 1594 SS_MENU_DATA_COLUMN,
1594 1595
1596 /**
1597 * This is the emblem to use for this status
1598 */
1599 SS_MENU_EMBLEM_COLUMN,
1600
1601 /**
1602 * And whether or not that emblem is visible
1603 */
1604 SS_MENU_EMBLEM_VISIBLE_COLUMN,
1605
1595 SS_MENU_NUM_COLUMNS 1606 SS_MENU_NUM_COLUMNS
1596 }; 1607 };
1597 1608
1598 static void 1609 static void
1599 status_menu_cb(GtkComboBox *widget, void(*callback)(PurpleSavedStatus*)) 1610 status_menu_cb(GtkComboBox *widget, void(*callback)(PurpleSavedStatus*))
1644 gtk_list_store_set(model, &iter, 1655 gtk_list_store_set(model, &iter,
1645 SS_MENU_TYPE_COLUMN, SS_MENU_ENTRY_TYPE_PRIMITIVE, 1656 SS_MENU_TYPE_COLUMN, SS_MENU_ENTRY_TYPE_PRIMITIVE,
1646 SS_MENU_ICON_COLUMN, pixbuf, 1657 SS_MENU_ICON_COLUMN, pixbuf,
1647 SS_MENU_TEXT_COLUMN, purple_primitive_get_name_from_type(primitive), 1658 SS_MENU_TEXT_COLUMN, purple_primitive_get_name_from_type(primitive),
1648 SS_MENU_DATA_COLUMN, GINT_TO_POINTER(primitive), 1659 SS_MENU_DATA_COLUMN, GINT_TO_POINTER(primitive),
1660 SS_MENU_EMBLEM_VISIBLE_COLUMN, FALSE,
1649 -1); 1661 -1);
1650 if (pixbuf != NULL) 1662 if (pixbuf != NULL)
1651 g_object_unref(pixbuf); 1663 g_object_unref(pixbuf);
1652 1664
1653 if (purple_savedstatus_is_transient(current_status) 1665 if (purple_savedstatus_is_transient(current_status)
1667 int index = -1; 1679 int index = -1;
1668 GdkPixbuf *pixbuf, *emblem; 1680 GdkPixbuf *pixbuf, *emblem;
1669 GtkTreeIter iter; 1681 GtkTreeIter iter;
1670 GtkCellRenderer *text_rend; 1682 GtkCellRenderer *text_rend;
1671 GtkCellRenderer *icon_rend; 1683 GtkCellRenderer *icon_rend;
1672 1684 GtkCellRenderer *emblem_rend;
1673 model = gtk_list_store_new(SS_MENU_NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER); 1685
1686 model = gtk_list_store_new(SS_MENU_NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF,
1687 G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN);
1674 1688
1675 combobox = gtk_combo_box_new(); 1689 combobox = gtk_combo_box_new();
1676 1690
1677 if (pidgin_status_menu_add_primitive(model, combobox, PURPLE_STATUS_AVAILABLE, current_status)) 1691 if (pidgin_status_menu_add_primitive(model, combobox, PURPLE_STATUS_AVAILABLE, current_status))
1678 index = i; 1692 index = i;
1695 for (cur = sorted; cur; cur = cur->next) 1709 for (cur = sorted; cur; cur = cur->next)
1696 { 1710 {
1697 PurpleSavedStatus *status = (PurpleSavedStatus *) cur->data; 1711 PurpleSavedStatus *status = (PurpleSavedStatus *) cur->data;
1698 if (!purple_savedstatus_is_transient(status)) 1712 if (!purple_savedstatus_is_transient(status))
1699 { 1713 {
1700 /* Get an appropriate status icon */
1701 pixbuf = pidgin_create_status_icon(purple_savedstatus_get_type(status), 1714 pixbuf = pidgin_create_status_icon(purple_savedstatus_get_type(status),
1702 combobox, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); 1715 combobox, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL);
1703
1704 /* Overlay a disk in the bottom left corner */
1705 emblem = gtk_widget_render_icon(GTK_WIDGET(combobox),
1706 GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU, "PidginStatusMenu");
1707 if (emblem != NULL)
1708 {
1709 /* copy the pixbuf so we're not modifying the stock image data when we overlay the disk */
1710 GdkPixbuf *pixbuf2 = gdk_pixbuf_copy(pixbuf);
1711 int width = gdk_pixbuf_get_width(pixbuf) / 2;
1712 int height = gdk_pixbuf_get_height(pixbuf) / 2;
1713
1714 g_object_unref(G_OBJECT(pixbuf));
1715 pixbuf = pixbuf2;
1716
1717 gdk_pixbuf_composite(emblem, pixbuf, 0, height,
1718 width, height, 0, height,
1719 0.5, 0.5, GDK_INTERP_BILINEAR, 255);
1720 g_object_unref(G_OBJECT(emblem));
1721 }
1722
1723 gtk_list_store_append(model, &iter); 1716 gtk_list_store_append(model, &iter);
1724 gtk_list_store_set(model, &iter, 1717 gtk_list_store_set(model, &iter,
1725 SS_MENU_TYPE_COLUMN, SS_MENU_ENTRY_TYPE_SAVEDSTATUS, 1718 SS_MENU_TYPE_COLUMN, SS_MENU_ENTRY_TYPE_SAVEDSTATUS,
1726 SS_MENU_ICON_COLUMN, pixbuf, 1719 SS_MENU_ICON_COLUMN, pixbuf,
1727 SS_MENU_TEXT_COLUMN, purple_savedstatus_get_title(status), 1720 SS_MENU_TEXT_COLUMN, purple_savedstatus_get_title(status),
1728 SS_MENU_DATA_COLUMN, GINT_TO_POINTER(purple_savedstatus_get_creation_time(status)), 1721 SS_MENU_DATA_COLUMN, GINT_TO_POINTER(purple_savedstatus_get_creation_time(status)),
1722 SS_MENU_EMBLEM_COLUMN, GTK_STOCK_SAVE,
1723 SS_MENU_EMBLEM_VISIBLE_COLUMN, TRUE,
1729 -1); 1724 -1);
1730 g_object_unref(G_OBJECT(pixbuf)); 1725 g_object_unref(G_OBJECT(pixbuf));
1731 1726
1732 if (status == current_status) 1727 if (status == current_status)
1733 index = i; 1728 index = i;
1738 1733
1739 gtk_combo_box_set_model(GTK_COMBO_BOX(combobox), GTK_TREE_MODEL(model)); 1734 gtk_combo_box_set_model(GTK_COMBO_BOX(combobox), GTK_TREE_MODEL(model));
1740 1735
1741 text_rend = gtk_cell_renderer_text_new(); 1736 text_rend = gtk_cell_renderer_text_new();
1742 icon_rend = gtk_cell_renderer_pixbuf_new(); 1737 icon_rend = gtk_cell_renderer_pixbuf_new();
1738 emblem_rend = gtk_cell_renderer_pixbuf_new();
1743 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), icon_rend, FALSE); 1739 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), icon_rend, FALSE);
1744 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), text_rend, TRUE); 1740 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), text_rend, TRUE);
1741 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), emblem_rend, FALSE);
1745 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), icon_rend, "pixbuf", SS_MENU_ICON_COLUMN, NULL); 1742 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), icon_rend, "pixbuf", SS_MENU_ICON_COLUMN, NULL);
1746 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), text_rend, "markup", SS_MENU_TEXT_COLUMN, NULL); 1743 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), text_rend, "markup", SS_MENU_TEXT_COLUMN, NULL);
1747 1744 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), emblem_rend,
1745 "stock-id", SS_MENU_EMBLEM_COLUMN, "visible", SS_MENU_EMBLEM_VISIBLE_COLUMN, NULL);
1748 1746
1749 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), index); 1747 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), index);
1750 g_signal_connect(G_OBJECT(combobox), "changed", G_CALLBACK(status_menu_cb), callback); 1748 g_signal_connect(G_OBJECT(combobox), "changed", G_CALLBACK(status_menu_cb), callback);
1751 1749
1752 return combobox; 1750 return combobox;

mercurial