Using a constant integer for the maximum number of characters (to be confirmed)

This commit is contained in:
Pierre Pronchery 2010-05-07 12:28:25 +00:00
parent 0c99914fc4
commit 9b7ef87fb6

View File

@ -434,6 +434,7 @@ void phone_hangup(Phone * phone)
void phone_messages_count_buffer(Phone * phone) void phone_messages_count_buffer(Phone * phone)
{ {
GtkTextBuffer * tbuf; GtkTextBuffer * tbuf;
const int max = 140;
gint cnt; gint cnt;
gint msg_cnt; gint msg_cnt;
gint cur_cnt; gint cur_cnt;
@ -442,16 +443,15 @@ void phone_messages_count_buffer(Phone * phone)
tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(phone->wr_view)); tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(phone->wr_view));
if((cnt = gtk_text_buffer_get_char_count(tbuf)) < 0) if((cnt = gtk_text_buffer_get_char_count(tbuf)) < 0)
return; return;
msg_cnt = (cnt / 140) + 1; msg_cnt = (cnt / max) + 1;
if((cur_cnt = cnt % 140) == 0) if((cur_cnt = cnt % max) == 0)
{ {
msg_cnt--; msg_cnt--;
if(cnt > 0) if(cnt > 0)
cur_cnt = 140; cur_cnt = max;
} }
snprintf(buf, sizeof(buf), _("%d message%s, %d/140 character%s"), snprintf(buf, sizeof(buf), _("%d message%s, %d/%d characters"),
msg_cnt, (msg_cnt > 1) ? _("s") : _(""), cur_cnt, msg_cnt, (msg_cnt > 1) ? _("s") : _(""), cur_cnt, max);
(cur_cnt > 1) ? _("s") : _(""));
gtk_label_set_text(GTK_LABEL(phone->wr_count), buf); gtk_label_set_text(GTK_LABEL(phone->wr_count), buf);
} }