pidgin/gtkstatusbox.c

branch
cpw.khc.ticket590
changeset 18183
31e06ec80111
parent 18121
2d8ea56b9097
child 18239
13364e0122f4
equal deleted inserted replaced
18182:ad8a38c32353 18183:31e06ec80111
45 #include "buddyicon.h" 45 #include "buddyicon.h"
46 #include "core.h" 46 #include "core.h"
47 #include "internal.h" 47 #include "internal.h"
48 #include "imgstore.h" 48 #include "imgstore.h"
49 #include "network.h" 49 #include "network.h"
50 #include "request.h"
50 #include "savedstatuses.h" 51 #include "savedstatuses.h"
51 #include "status.h" 52 #include "status.h"
52 #include "debug.h" 53 #include "debug.h"
53 54
54 #include "pidgin.h" 55 #include "pidgin.h"
1221 /* Make sure our current status is added to the list of popular statuses */ 1222 /* Make sure our current status is added to the list of popular statuses */
1222 pidgin_status_box_regenerate(status_box); 1223 pidgin_status_box_regenerate(status_box);
1223 } 1224 }
1224 1225
1225 static void 1226 static void
1227 saved_status_updated_cb(PurpleSavedStatus *status, PidginStatusBox *status_box)
1228 {
1229 pidgin_status_box_regenerate(status_box);
1230 }
1231
1232 static void
1226 spellcheck_prefs_cb(const char *name, PurplePrefType type, 1233 spellcheck_prefs_cb(const char *name, PurplePrefType type,
1227 gconstpointer value, gpointer data) 1234 gconstpointer value, gpointer data)
1228 { 1235 {
1229 #ifdef USE_GTKSPELL 1236 #ifdef USE_GTKSPELL
1230 PidginStatusBox *status_box = (PidginStatusBox *)data; 1237 PidginStatusBox *status_box = (PidginStatusBox *)data;
1512 status_box->active_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(status_box->dropdown_store), path); 1519 status_box->active_row = gtk_tree_row_reference_new(GTK_TREE_MODEL(status_box->dropdown_store), path);
1513 pidgin_status_box_popdown (status_box); 1520 pidgin_status_box_popdown (status_box);
1514 pidgin_status_box_changed(status_box); 1521 pidgin_status_box_changed(status_box);
1515 } 1522 }
1516 1523
1524 static void tree_view_delete_current_selection_cb(gpointer data)
1525 {
1526 PurpleSavedStatus *saved;
1527
1528 saved = purple_savedstatus_find_by_creation_time(GPOINTER_TO_INT(data));
1529 g_return_if_fail(saved != NULL);
1530
1531 if (purple_savedstatus_get_current() != saved)
1532 purple_savedstatus_delete_by_status(saved);
1533 }
1534
1535 static void
1536 tree_view_delete_current_selection(PidginStatusBox *status_box, GtkTreePath *path)
1537 {
1538 GtkTreeIter iter;
1539 gpointer data;
1540 PurpleSavedStatus *saved;
1541 gchar *msg;
1542
1543 if (status_box->active_row) {
1544 /* don't delete active status */
1545 if (gtk_tree_path_compare(path, gtk_tree_row_reference_get_path(status_box->active_row)) == 0)
1546 return;
1547 }
1548
1549 if (!gtk_tree_model_get_iter (GTK_TREE_MODEL(status_box->dropdown_store), &iter, path))
1550 return;
1551
1552 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter,
1553 DATA_COLUMN, &data,
1554 -1);
1555
1556 saved = purple_savedstatus_find_by_creation_time(GPOINTER_TO_INT(data));
1557 g_return_if_fail(saved != NULL);
1558 if (saved == purple_savedstatus_get_current())
1559 return;
1560
1561 msg = g_strdup_printf(_("Are you sure you want to delete %s?"), purple_savedstatus_get_title(saved));
1562
1563 purple_request_action(pidgin_status_get_handle(), NULL, msg, NULL, 0,
1564 NULL, NULL, NULL,
1565 data, 2,
1566 _("Delete"), tree_view_delete_current_selection_cb,
1567 _("Cancel"), NULL);
1568
1569 g_free(msg);
1570
1571 pidgin_status_box_popdown(status_box);
1572 }
1573
1517 static gboolean 1574 static gboolean
1518 treeview_button_release_cb(GtkWidget *widget, GdkEventButton *event, PidginStatusBox *status_box) 1575 treeview_button_release_cb(GtkWidget *widget, GdkEventButton *event, PidginStatusBox *status_box)
1519 { 1576 {
1520 GtkTreePath *path = NULL; 1577 GtkTreePath *path = NULL;
1521 int ret; 1578 int ret;
1559 { 1616 {
1560 if (box->popup_in_progress) { 1617 if (box->popup_in_progress) {
1561 if (event->keyval == GDK_Escape) { 1618 if (event->keyval == GDK_Escape) {
1562 pidgin_status_box_popdown(box); 1619 pidgin_status_box_popdown(box);
1563 return TRUE; 1620 return TRUE;
1564 } else if (event->keyval == GDK_Return) { 1621 } else {
1565 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(box->tree_view)); 1622 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(box->tree_view));
1566 GtkTreeIter iter; 1623 GtkTreeIter iter;
1567 GtkTreePath *path; 1624 GtkTreePath *path;
1568 1625
1569 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { 1626 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) {
1570 path = gtk_tree_model_get_path(GTK_TREE_MODEL(box->dropdown_store), &iter); 1627 path = gtk_tree_model_get_path(GTK_TREE_MODEL(box->dropdown_store), &iter);
1571 treeview_activate_current_selection(box, path); 1628 if (event->keyval == GDK_Return) {
1629 treeview_activate_current_selection(box, path);
1630 } else if (event->keyval == GDK_Delete) {
1631 tree_view_delete_current_selection(box, path);
1632 }
1633
1572 gtk_tree_path_free (path); 1634 gtk_tree_path_free (path);
1573 return TRUE; 1635 return TRUE;
1574 } 1636 }
1575 } 1637 }
1576 } 1638 }
1577 return FALSE; 1639 return FALSE;
1578 } 1640 }
1579 1641
1580 static void 1642 static void
1740 1802
1741 purple_signal_connect(purple_savedstatuses_get_handle(), "savedstatus-changed", 1803 purple_signal_connect(purple_savedstatuses_get_handle(), "savedstatus-changed",
1742 status_box, 1804 status_box,
1743 PURPLE_CALLBACK(current_savedstatus_changed_cb), 1805 PURPLE_CALLBACK(current_savedstatus_changed_cb),
1744 status_box); 1806 status_box);
1807 purple_signal_connect(purple_savedstatuses_get_handle(),
1808 "savedstatus-added", status_box,
1809 PURPLE_CALLBACK(saved_status_updated_cb), status_box);
1810 purple_signal_connect(purple_savedstatuses_get_handle(),
1811 "savedstatus-deleted", status_box,
1812 PURPLE_CALLBACK(saved_status_updated_cb), status_box);
1813 purple_signal_connect(purple_savedstatuses_get_handle(),
1814 "savedstatus-modified", status_box,
1815 PURPLE_CALLBACK(saved_status_updated_cb), status_box);
1745 purple_signal_connect(purple_accounts_get_handle(), "account-enabled", status_box, 1816 purple_signal_connect(purple_accounts_get_handle(), "account-enabled", status_box,
1746 PURPLE_CALLBACK(account_enabled_cb), 1817 PURPLE_CALLBACK(account_enabled_cb),
1747 status_box); 1818 status_box);
1748 purple_signal_connect(purple_accounts_get_handle(), "account-disabled", status_box, 1819 purple_signal_connect(purple_accounts_get_handle(), "account-disabled", status_box,
1749 PURPLE_CALLBACK(account_enabled_cb), 1820 PURPLE_CALLBACK(account_enabled_cb),

mercurial