Changeset 4240


Ignore:
Timestamp:
Dec 20, 2007, 2:56:47 AM (14 years ago)
Author:
charles
Message:

(gtk) add the up/down/yin-yang icons and session stats to toolbar. add toggling of toolbar and/or statusbar.

Location:
trunk/gtk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/actions.c

    r4235 r4240  
    2121#include "lock.h"
    2222#include "logo.h"
     23#include "status-bar-icons.h"
    2324
    2425#define UNUSED G_GNUC_UNUSED
     
    102103    N_("_Minimal View"), "<alt>M", NULL, G_CALLBACK(toggle_pref_cb), FALSE },
    103104  { "sort-reversed", NULL,
    104     N_("_Reverse Sort Order"), NULL, NULL, G_CALLBACK(toggle_pref_cb), FALSE }
     105    N_("_Reverse Sort Order"), NULL, NULL, G_CALLBACK(toggle_pref_cb), FALSE },
     106  { "show-status-bar", NULL,
     107    N_("Show _Status Bar"), NULL, NULL, G_CALLBACK(toggle_pref_cb), FALSE },
     108  { "show-toolbar", NULL,
     109    N_("Show _Toolbar"), NULL, NULL, G_CALLBACK(toggle_pref_cb), FALSE }
    105110};
    106111
     
    169174{
    170175    { tr_icon_logo, "transmission-logo" },
    171     { tr_icon_lock, "transmission-lock" }
     176    { tr_icon_lock, "transmission-lock" },
     177    { tr_arrow_down, "tr-arrow-down" },
     178    { tr_arrow_up, "tr-arrow-up" },
     179    { tr_yin_yang, "tr-yin-yang" }
    172180};
    173181
     
    236244
    237245  match = pref_string_get( PREF_KEY_SORT_MODE );
    238   for( i=0, n=G_N_ELEMENTS(sort_radio_entries), active=-1; active==-1 && i<n; ++i ) {
    239       if( !strcmp( sort_radio_entries[i].name, match ) ) {
    240           g_message( "found %s in index %d", match, i );
     246  for( i=0, n=G_N_ELEMENTS(sort_radio_entries), active=-1; active==-1 && i<n; ++i )
     247      if( !strcmp( sort_radio_entries[i].name, match ) )
    241248          active = i;
    242       }
    243   }
    244249
    245250  gtk_action_group_add_radio_actions( action_group,
  • trunk/gtk/tr_prefs.c

    r4210 r4240  
    3030    cf_check_older_configs( );
    3131
     32    pref_flag_set_default   ( PREF_KEY_STATUS_BAR, TRUE );
     33    pref_flag_set_default   ( PREF_KEY_TOOLBAR, TRUE );
     34
    3235    pref_flag_set_default   ( PREF_KEY_DL_LIMIT_ENABLED, FALSE );
    3336    pref_int_set_default    ( PREF_KEY_DL_LIMIT, 100 );
  • trunk/gtk/tr_prefs.h

    r4210 r4240  
    3939#define PREF_KEY_SORT_REVERSED     "sort-reversed"
    4040#define PREF_KEY_MINIMAL_VIEW      "minimal-view"
     41#define PREF_KEY_STATUS_BAR        "show-status-bar"
     42#define PREF_KEY_TOOLBAR           "show-toolbar"
    4143
    4244void tr_prefs_init_global( void );
  • trunk/gtk/tr_window.c

    r4238 r4240  
    5353    GtkWidget * scroll;
    5454    GtkWidget * view;
     55    GtkWidget * toolbar;
    5556    GtkWidget * status;
    5657    GtkWidget * ul_lb;
    5758    GtkWidget * dl_lb;
     59    GtkWidget * stats_lb;
    5860    GtkTreeSelection  * selection;
    5961    GtkCellRenderer   * renderer;
     
    145147prefsChanged( TrCore * core UNUSED, const char * key, gpointer wind )
    146148{
     149    PrivateData * p = get_private_data( GTK_WINDOW( wind ) );
     150
    147151    if( !strcmp( key, PREF_KEY_MINIMAL_VIEW ) )
    148152    {
    149        PrivateData * p = get_private_data( GTK_WINDOW( wind ) );
    150153       g_object_set( p->renderer, "minimal", pref_flag_get( key ), NULL );
    151154       gtk_tree_view_column_queue_resize( p->column );
     155    }
     156    else if( !strcmp( key, PREF_KEY_STATUS_BAR ) )
     157    {
     158        const gboolean isEnabled = pref_flag_get( key );
     159        g_object_set( p->status, "visible", isEnabled, NULL );
     160    }
     161    else if( !strcmp( key, PREF_KEY_TOOLBAR ) )
     162    {
     163        const gboolean isEnabled = pref_flag_get( key );
     164        g_object_set( p->toolbar, "visible", isEnabled, NULL );
    152165    }
    153166}
     
    189202
    190203    /* toolbar */
    191     w = action_get_widget( "/main-window-toolbar" );
     204    w = p->toolbar = action_get_widget( "/main-window-toolbar" );
    192205    gtk_box_pack_start( GTK_BOX(vbox), w, FALSE, FALSE, 0 );
     206
     207    /* statusbar */
     208    h = p->status = gtk_hbox_new( FALSE, GUI_PAD );
     209    gtk_container_set_border_width( GTK_CONTAINER(h), GUI_PAD );
     210     
     211    w = p->ul_lb = gtk_label_new( NULL );
     212    gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
     213    w = gtk_image_new_from_stock( "tr-arrow-up", (GtkIconSize)-1 );
     214    gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
     215    w = gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f );
     216    gtk_widget_set_usize( w, GUI_PAD, 0u );
     217    gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
     218    w = p->dl_lb = gtk_label_new( NULL );
     219    gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
     220    w = gtk_image_new_from_stock( "tr-arrow-down", (GtkIconSize)-1 );
     221    gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
     222
     223    w = gtk_image_new_from_stock( "tr-yin-yang", (GtkIconSize)-1 );
     224    gtk_box_pack_start( GTK_BOX(h), w, FALSE, FALSE, 0 );
     225    w = p->stats_lb = gtk_label_new( NULL );
     226    gtk_box_pack_start( GTK_BOX(h), w, FALSE, FALSE, 0 );
     227
     228    gtk_box_pack_start( GTK_BOX(vbox), h, FALSE, FALSE, 0 );
    193229
    194230    /* workarea */
     
    204240    gtk_box_pack_start( GTK_BOX(vbox), w, FALSE, FALSE, 0 );
    205241
    206     /* statusbar */
    207     h = gtk_hbox_new( FALSE, 0 );
    208     w = p->ul_lb = gtk_label_new( NULL );
    209     gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, GUI_PAD );
    210     w = gtk_vseparator_new( );
    211     gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, GUI_PAD );
    212     w = p->dl_lb = gtk_label_new( NULL );
    213     gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, GUI_PAD );
    214     gtk_box_pack_start( GTK_BOX(vbox), h, FALSE, FALSE, 0 );
    215 
    216242    /* show all but the window */
    217243    gtk_widget_show_all( vbox );
     
    219245    /* listen for prefs changes that affect the window */
    220246    prefsChanged( core, PREF_KEY_MINIMAL_VIEW, self );
     247    prefsChanged( core, PREF_KEY_STATUS_BAR, self );
     248    prefsChanged( core, PREF_KEY_TOOLBAR, self );
    221249    p->core = core;
    222250    p->pref_handler_id = g_signal_connect( core, "prefs-changed",
     
    230258{
    231259    PrivateData * p = get_private_data( self );
    232     char speedStr[32];
    233     char buf[64];
    234 
    235     tr_strlspeed( speedStr, downspeed, sizeof(speedStr) );
    236     g_snprintf( buf, sizeof(buf), _("Down: %s"), speedStr );
    237     gtk_label_set_text( GTK_LABEL(p->dl_lb), buf );
    238 
    239     tr_strlspeed( speedStr, upspeed, sizeof(speedStr) );
    240     g_snprintf( buf, sizeof(buf), _("Up: %s"), speedStr );
    241     gtk_label_set_text( GTK_LABEL(p->ul_lb), buf );
     260    char up[32], down[32], buf[64];
     261    struct tr_session_stats stats;
     262    tr_handle * handle = tr_core_handle( p->core );
     263
     264    tr_strlspeed( buf, downspeed, sizeof( buf ) );
     265    gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf );
     266
     267    tr_strlspeed( buf, upspeed, sizeof( buf ) );
     268    gtk_label_set_text( GTK_LABEL( p->ul_lb ), buf );
     269
     270    tr_getCumulativeSessionStats( handle, &stats );
     271    tr_strlsize( up, stats.uploadedBytes, sizeof( up ) );
     272    tr_strlsize( down, stats.downloadedBytes, sizeof( down ) );
     273    g_snprintf( buf, sizeof( buf ), _( "Down: %s  Up: %s" ), down, up );
     274    gtk_label_set_text( GTK_LABEL( p->stats_lb ), buf );
    242275}
    243276
  • trunk/gtk/ui.h

    r4221 r4240  
    1616"    </menu>\n"
    1717"    <menu action='view-menu'>\n"
     18"      <menuitem action='minimal-view'/>\n"
     19"      <separator/>\n"
     20"      <menu action='sort-menu'>\n"
     21"          <menuitem action='sort-by-activity'/>\n"
     22"          <menuitem action='sort-by-name'/>\n"
     23"          <menuitem action='sort-by-progress'/>\n"
     24"          <menuitem action='sort-by-state'/>\n"
     25"          <menuitem action='sort-by-tracker'/>\n"
     26"          <separator/>\n"
     27"          <menuitem action='sort-reversed'/>\n"
     28"      </menu>\n"
     29"      <separator/>\n"
    1830"      <menuitem action='show-torrent-details'/>\n"
    1931"      <separator/>\n"
    20 "      <menuitem action='minimal-view'/>\n"
     32"      <menuitem action='show-toolbar'/>\n"
     33"      <menuitem action='show-status-bar'/>\n"
    2134"      <separator/>\n"
    22 "      <menuitem action='sort-by-activity'/>\n"
    23 "      <menuitem action='sort-by-name'/>\n"
    24 "      <menuitem action='sort-by-progress'/>\n"
    25 "      <menuitem action='sort-by-state'/>\n"
    26 "      <menuitem action='sort-by-tracker'/>\n"
    27 "      <menuitem action='sort-reversed'/>\n"
    2835"    </menu>\n"
    2936"    <menu action='edit-menu'>\n"
Note: See TracChangeset for help on using the changeset viewer.