comparison src/gtkaccount.c @ 7179:819905ce7bc0

[gaim-migrate @ 7747] The protocol icon for an account in the accounts window will now "pulse" when signing the account on. It provides a nice visual effect showing that an account is attempting to connect, without hiding any information or taking up additional screen real-estate. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 06 Oct 2003 22:13:08 +0000
parents 669af8c0801a
children 439b83f4a833
comparison
equal deleted inserted replaced
7178:eb3356588ef5 7179:819905ce7bc0
47 COLUMN_SCREENNAME, 47 COLUMN_SCREENNAME,
48 COLUMN_ONLINE, 48 COLUMN_ONLINE,
49 COLUMN_AUTOLOGIN, 49 COLUMN_AUTOLOGIN,
50 COLUMN_PROTOCOL, 50 COLUMN_PROTOCOL,
51 COLUMN_DATA, 51 COLUMN_DATA,
52 COLUMN_PULSE_DATA,
52 NUM_COLUMNS 53 NUM_COLUMNS
53 }; 54 };
54 55
55 typedef struct 56 typedef struct
56 { 57 {
129 GtkWidget *proxy_port_entry; 130 GtkWidget *proxy_port_entry;
130 GtkWidget *proxy_user_entry; 131 GtkWidget *proxy_user_entry;
131 GtkWidget *proxy_pass_entry; 132 GtkWidget *proxy_pass_entry;
132 133
133 } AccountPrefsDialog; 134 } AccountPrefsDialog;
135
136 typedef struct
137 {
138 GdkPixbuf *online_pixbuf;
139 gboolean pulse_to_grey;
140 float pulse_value;
141 int timeout;
142 GaimAccount *account;
143 GtkTreeModel *model;
144
145 } GaimGtkPulseData;
134 146
135 147
136 static AccountsWindow *accounts_window = NULL; 148 static AccountsWindow *accounts_window = NULL;
137 149
138 static void add_account(AccountsWindow *dialog, GaimAccount *account); 150 static void add_account(AccountsWindow *dialog, GaimAccount *account);
1289 } 1301 }
1290 1302
1291 /************************************************************************** 1303 /**************************************************************************
1292 * Accounts Dialog 1304 * Accounts Dialog
1293 **************************************************************************/ 1305 **************************************************************************/
1306 static void
1307 account_pulse_update(GaimGtkPulseData *pulse_data)
1308 {
1309 GdkPixbuf *pixbuf;
1310 GtkTreeIter iter;
1311 size_t index = g_list_index(gaim_accounts_get_all(), pulse_data->account);
1312
1313 if (gtk_tree_model_iter_nth_child(pulse_data->model, &iter, NULL, index))
1314 {
1315 pixbuf = gdk_pixbuf_copy(pulse_data->online_pixbuf);
1316
1317 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf,
1318 pulse_data->pulse_value, FALSE);
1319
1320 if (pulse_data->pulse_to_grey)
1321 pulse_data->pulse_value += 0.20;
1322 else
1323 pulse_data->pulse_value -= 0.20;
1324
1325 if (pulse_data->pulse_value >= 1)
1326 pulse_data->pulse_to_grey = FALSE;
1327 else if (pulse_data->pulse_value <= 0)
1328 pulse_data->pulse_to_grey = TRUE;
1329
1330 gtk_list_store_set(GTK_LIST_STORE(pulse_data->model), &iter,
1331 COLUMN_ICON, pixbuf, -1);
1332
1333 if (pixbuf != NULL)
1334 g_object_unref(G_OBJECT(pixbuf));
1335 }
1336 }
1294 1337
1295 static void 1338 static void
1296 signed_on_off_cb(GaimConnection *gc, AccountsWindow *dialog) 1339 signed_on_off_cb(GaimConnection *gc, AccountsWindow *dialog)
1297 { 1340 {
1298 GaimAccount *account = gaim_connection_get_account(gc); 1341 GaimAccount *account = gaim_connection_get_account(gc);
1342 GaimGtkPulseData *pulse_data;
1299 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); 1343 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model);
1300 GtkTreeIter iter; 1344 GtkTreeIter iter;
1301 GdkPixbuf *pixbuf, *scale = NULL; 1345 GdkPixbuf *pixbuf, *scale = NULL;
1302 size_t index = g_list_index(gaim_accounts_get_all(), account); 1346 size_t index = g_list_index(gaim_accounts_get_all(), account);
1303 1347
1304 if (gtk_tree_model_iter_nth_child(model, &iter, NULL, index)) 1348 if (gtk_tree_model_iter_nth_child(model, &iter, NULL, index))
1305 { 1349 {
1350 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter,
1351 COLUMN_PULSE_DATA, &pulse_data, -1);
1352
1353 if (pulse_data != NULL)
1354 {
1355 if (pulse_data->timeout > 0)
1356 g_source_remove(pulse_data->timeout);
1357
1358 g_object_unref(G_OBJECT(pulse_data->online_pixbuf));
1359
1360 g_free(pulse_data);
1361 }
1362
1306 pixbuf = create_prpl_icon(account); 1363 pixbuf = create_prpl_icon(account);
1307 1364
1308 if (pixbuf != NULL) 1365 if (pixbuf != NULL)
1309 { 1366 {
1310 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, 1367 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
1315 } 1372 }
1316 1373
1317 gtk_list_store_set(dialog->model, &iter, 1374 gtk_list_store_set(dialog->model, &iter,
1318 COLUMN_ICON, scale, 1375 COLUMN_ICON, scale,
1319 COLUMN_ONLINE, gaim_account_is_connected(account), 1376 COLUMN_ONLINE, gaim_account_is_connected(account),
1377 COLUMN_PULSE_DATA, NULL,
1320 -1); 1378 -1);
1321 1379
1322 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); 1380 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf));
1323 if (scale != NULL) g_object_unref(G_OBJECT(scale)); 1381 if (scale != NULL) g_object_unref(G_OBJECT(scale));
1324 } 1382 }
1579 { 1637 {
1580 AccountsWindow *dialog = (AccountsWindow *)data; 1638 AccountsWindow *dialog = (AccountsWindow *)data;
1581 GaimAccount *account; 1639 GaimAccount *account;
1582 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); 1640 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model);
1583 GtkTreeIter iter; 1641 GtkTreeIter iter;
1642 GaimGtkPulseData *pulse_data;
1584 gboolean online; 1643 gboolean online;
1585 1644
1586 gtk_tree_model_get_iter_from_string(model, &iter, path_str); 1645 gtk_tree_model_get_iter_from_string(model, &iter, path_str);
1587 gtk_tree_model_get(model, &iter, 1646 gtk_tree_model_get(model, &iter,
1588 COLUMN_DATA, &account, 1647 COLUMN_DATA, &account,
1589 COLUMN_ONLINE, &online, 1648 COLUMN_ONLINE, &online,
1590 -1); 1649 -1);
1591 1650
1592 if (online) { 1651 if (online)
1652 {
1593 account->gc->wants_to_die = TRUE; 1653 account->gc->wants_to_die = TRUE;
1594 gaim_account_disconnect(account); 1654 gaim_account_disconnect(account);
1595 } else { 1655 }
1656 else
1657 {
1658 GdkPixbuf *pixbuf;
1659
1660 pulse_data = g_new0(GaimGtkPulseData, 1);
1661 pulse_data->pulse_to_grey = TRUE;
1662 pulse_data->pulse_value = 0;
1663 pulse_data->account = account;
1664 pulse_data->model = model;
1665
1666 pixbuf = create_prpl_icon(account);
1667
1668 if (pixbuf != NULL)
1669 {
1670 pulse_data->online_pixbuf =
1671 gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
1672
1673 g_object_unref(G_OBJECT(pixbuf));
1674 }
1675
1676 if (pulse_data->online_pixbuf == NULL)
1677 {
1678 g_free(pulse_data);
1679 }
1680 else
1681 {
1682 pulse_data->timeout = g_timeout_add(100,
1683 (GSourceFunc)account_pulse_update, pulse_data);
1684
1685 gtk_list_store_set(GTK_LIST_STORE(model), &iter,
1686 COLUMN_PULSE_DATA, pulse_data);
1687 }
1688
1596 gaim_account_connect(account); 1689 gaim_account_connect(account);
1597 } 1690 }
1598 } 1691 }
1599 1692
1600 static void 1693 static void
1756 1849
1757 /* Create the list model. */ 1850 /* Create the list model. */
1758 dialog->model = gtk_list_store_new(NUM_COLUMNS, 1851 dialog->model = gtk_list_store_new(NUM_COLUMNS,
1759 GDK_TYPE_PIXBUF, G_TYPE_STRING, 1852 GDK_TYPE_PIXBUF, G_TYPE_STRING,
1760 G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, 1853 G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
1761 G_TYPE_STRING, G_TYPE_POINTER); 1854 G_TYPE_STRING, G_TYPE_POINTER,
1855 G_TYPE_POINTER);
1762 1856
1763 /* And now the actual treeview */ 1857 /* And now the actual treeview */
1764 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model)); 1858 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model));
1765 dialog->treeview = treeview; 1859 dialog->treeview = treeview;
1766 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); 1860 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);