Changeset 13983


Ignore:
Timestamp:
Feb 8, 2013, 1:34:59 AM (8 years ago)
Author:
jordan
Message:

(gtk) match transmission-qt's way of showing up & down speeds in the statusbar

Location:
trunk/gtk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-core.c

    r13899 r13983  
    198198                    G_TYPE_DOUBLE,    /* tr_stat.pieceUploadSpeed_KBps */
    199199                    G_TYPE_DOUBLE,    /* tr_stat.pieceDownloadSpeed_KBps */
     200                    G_TYPE_INT,       /* tr_stat.peersGettingFromUs */
     201                    G_TYPE_INT,       /* tr_stat.peersSendingToUs + webseedsSendingToUs */
    200202                    G_TYPE_DOUBLE,    /* tr_stat.recheckProgress */
    201203                    G_TYPE_BOOLEAN,   /* filter.c:ACTIVITY_FILTER_ACTIVE */
     
    10791081        MC_SPEED_UP,          st->pieceUploadSpeed_KBps,
    10801082        MC_SPEED_DOWN,        st->pieceDownloadSpeed_KBps,
     1083        MC_ACTIVE_PEERS_UP,   st->peersGettingFromUs,
     1084        MC_ACTIVE_PEERS_DOWN, st->peersSendingToUs + st->webseedsSendingToUs,
    10811085        MC_RECHECK_PROGRESS,  st->recheckProgress,
    10821086        MC_ACTIVE,            is_torrent_active (st),
     
    14291433  bool oldFinished, newFinished;
    14301434  int oldQueuePosition, newQueuePosition;
     1435  int oldDownloadPeerCount, newDownloadPeerCount;
     1436  int oldUploadPeerCount, newUploadPeerCount;
    14311437  tr_priority_t oldPriority, newPriority;
    14321438  unsigned int oldTrackers, newTrackers;
     
    14431449                      MC_ACTIVE, &oldActive,
    14441450                      MC_ACTIVE_PEER_COUNT, &oldActivePeerCount,
     1451                      MC_ACTIVE_PEERS_UP, &oldUploadPeerCount,
     1452                      MC_ACTIVE_PEERS_DOWN, &oldDownloadPeerCount,
    14451453                      MC_ERROR, &oldError,
    14461454                      MC_ACTIVITY, &oldActivity,
     
    14661474  newRecheckProgress = st->recheckProgress;
    14671475  newActivePeerCount = st->peersSendingToUs + st->peersGettingFromUs + st->webseedsSendingToUs;
     1476  newDownloadPeerCount = st->peersSendingToUs;
     1477  newUploadPeerCount = st->peersGettingFromUs + st->webseedsSendingToUs;
    14681478  newError = st->error;
    14691479
     
    14771487        || (newError != oldError)
    14781488        || (newActivePeerCount != oldActivePeerCount)
     1489        || (newDownloadPeerCount != oldDownloadPeerCount)
     1490        || (newUploadPeerCount != oldUploadPeerCount)
    14791491        || (newTrackers != oldTrackers)
    14801492        || gtr_compare_double (newUpSpeed, oldUpSpeed, 2)
     
    14851497                          MC_ACTIVE, newActive,
    14861498                          MC_ACTIVE_PEER_COUNT, newActivePeerCount,
     1499                          MC_ACTIVE_PEERS_UP, newUploadPeerCount,
     1500                          MC_ACTIVE_PEERS_DOWN, newDownloadPeerCount,
    14871501                          MC_ERROR, newError,
    14881502                          MC_ACTIVITY, newActivity,
  • trunk/gtk/tr-core.h

    r13758 r13983  
    174174    MC_SPEED_UP,
    175175    MC_SPEED_DOWN,
     176    MC_ACTIVE_PEERS_UP,
     177    MC_ACTIVE_PEERS_DOWN,
    176178    MC_RECHECK_PROGRESS,
    177179    MC_ACTIVE,
  • trunk/gtk/tr-window.c

    r13928 r13983  
    741741  gtk_grid_attach_next_to (grid, w, sibling, GTK_POS_RIGHT, 1, 1);
    742742  sibling = w;
    743   w = gtk_image_new_from_stock (GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU);
    744   g_object_set (G_OBJECT(w), "margin-left", GUI_PAD, NULL);
    745   gtk_grid_attach_next_to (grid, w, sibling, GTK_POS_RIGHT, 1, 1);
    746   sibling = w;
    747743
    748744  /* upload */
     
    751747  p->ul_lb = GTK_LABEL (w);
    752748  gtk_label_set_single_line_mode (p->ul_lb, TRUE);
    753   gtk_grid_attach_next_to (grid, w, sibling, GTK_POS_RIGHT, 1, 1);
    754   sibling = w;
    755   w = gtk_image_new_from_stock (GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU);
    756   g_object_set (G_OBJECT(w), "margin-left", GUI_PAD, NULL);
    757749  gtk_grid_attach_next_to (grid, w, sibling, GTK_POS_RIGHT, 1, 1);
    758750  sibling = w;
     
    819811  tr_sessionSetAltSpeedFunc (gtr_core_session (core), onAltSpeedToggled, p);
    820812
     813  gtr_window_refresh (GTK_WINDOW(self));
    821814  return self;
    822815}
     
    919912  if (session != NULL)
    920913    {
    921       char buf[128];
    922       double up=0, down=0;
     914      char text_str[256];
     915      char speed_str[128];
     916      double upSpeed = 0;
     917      double downSpeed = 0;
     918      int upCount = 0;
     919      int downCount = 0;
    923920      GtkTreeIter iter;
    924921      GtkTreeModel * model = gtr_core_model (p->core);
    925922
     923
    926924      if (gtk_tree_model_iter_nth_child (model, &iter, NULL, 0)) do
    927925        {
    928           double u, d;
    929           gtk_tree_model_get (model, &iter, MC_SPEED_UP, &u,
    930                                             MC_SPEED_DOWN, &d,
     926          int uc, dc;
     927          double us, ds;
     928          gtk_tree_model_get (model, &iter, MC_SPEED_UP, &us,
     929                                            MC_SPEED_DOWN, &ds,
     930                                            MC_ACTIVE_PEERS_UP, &uc,
     931                                            MC_ACTIVE_PEERS_DOWN, &dc,
    931932                                            -1);
    932           up += u;
    933           down += d;
     933          upSpeed += us;
     934          upCount += uc;
     935          downSpeed += ds;
     936          downCount += dc;
    934937        }
    935938      while (gtk_tree_model_iter_next (model, &iter));
    936939
    937       tr_formatter_speed_KBps (buf, down, sizeof (buf));
    938       gtr_label_set_text (p->dl_lb, buf);
    939 
    940       tr_formatter_speed_KBps (buf, up, sizeof (buf));
    941       gtr_label_set_text (p->ul_lb, buf);
     940      tr_formatter_speed_KBps (speed_str, downSpeed, sizeof (speed_str));
     941      g_snprintf (text_str, sizeof(text_str), "%s %s", speed_str, gtr_get_unicode_string (GTR_UNICODE_DOWN));
     942      gtr_label_set_text (p->dl_lb, text_str);
     943      gtk_widget_set_visible (GTK_WIDGET (p->dl_lb), (downCount>0));
     944
     945      tr_formatter_speed_KBps (speed_str, upSpeed, sizeof (speed_str));
     946      g_snprintf (text_str, sizeof(text_str), "%s %s", speed_str, gtr_get_unicode_string (GTR_UNICODE_UP));
     947      gtr_label_set_text (p->ul_lb, text_str);
     948      gtk_widget_set_visible (GTK_WIDGET (p->ul_lb), ((downCount>0) || (upCount>0)));
    942949    }
    943950}
Note: See TracChangeset for help on using the changeset viewer.