Changeset 4222


Ignore:
Timestamp:
Dec 19, 2007, 7:16:36 PM (14 years ago)
Author:
charles
Message:

more progress on prefs + event integration

Location:
trunk/gtk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r4221 r4222  
    265265        ( didlock || cf_lock( &err ) ) )
    266266    {
     267        cbdata->core = tr_core_new( );
     268
    267269        /* create main window now to be a parent to any error dialogs */
    268         GtkWindow * mainwind = GTK_WINDOW( tr_window_new( myUIManager ) );
     270        GtkWindow * mainwind = GTK_WINDOW( tr_window_new( myUIManager, cbdata->core ) );
    269271
    270272        /* set message level here before tr_init() */
    271273        msgwin_loadpref( );
     274
    272275        appsetup( mainwind, argfiles, cbdata, startpaused );
    273276    }
     
    310313    /* fill out cbdata */
    311314    cbdata->wind       = NULL;
    312     cbdata->core       = tr_core_new();
    313315    cbdata->icon       = NULL;
    314316    cbdata->msgwin     = NULL;
     
    669671        PREF_KEY_PEX,
    670672        PREF_KEY_SYSTRAY,
    671         PREF_KEY_SORT_MODE,
    672         PREF_KEY_SORT_REVERSED,
    673         PREF_KEY_MINIMAL_VIEW,
    674673        PREF_KEY_ENCRYPTED_ONLY
    675674    };
     
    737736        gboolean enabled = pref_flag_get( key );
    738737        tr_torrentIterate( tr, setpex, &enabled );
    739     }
    740     else if( !strcmp( key, PREF_KEY_MINIMAL_VIEW ) )
    741     {
    742         const gboolean enabled = pref_flag_get( key );
    743         g_message( "minimal view: %d", enabled );
    744738    }
    745739}
  • trunk/gtk/torrent-cell-renderer.c

    r4220 r4222  
    300300        }
    301301
     302g_message ("width %d height %d", *width, *height );
    302303        *width = w + xpad*2;
    303304        *height = h + ypad*2;
     
    556557        case P_TORRENT:             p->tor = g_value_get_pointer( v ); break;
    557558        case P_BAR_HEIGHT:          p->bar_height = g_value_get_int( v ); break;
    558         case P_MINIMAL:             p->minimal  = g_value_get_boolean( v ); break;
     559        case P_MINIMAL:             { p->minimal  = g_value_get_boolean( v ); g_message("setting minimal to %d", p->minimal ); break; }
    559560        case P_GRADIENT:            p->gradient = g_value_get_boolean( v ); break;
    560561        case P_SHOW_UNAVAILABLE:    p->show_unavailable = g_value_get_boolean( v ); break;
     
    587588    g_value_set_string( value, buf );
    588589}
    589 
    590590
    591591static void
  • trunk/gtk/tr_core.c

    r4221 r4222  
    397397{
    398398    TrCore * core = TR_CORE( g_object_new( TR_CORE_TYPE, NULL ) );
     399
     400    /* init from prefs & listen to pref changes */
    399401    g_signal_connect( core, "prefs-changed", G_CALLBACK(prefsChanged), NULL );
     402    prefsChanged( core, PREF_KEY_SORT_MODE, NULL );
     403    prefsChanged( core, PREF_KEY_SORT_REVERSED, NULL );
     404
    400405    return core;
    401406}
  • trunk/gtk/tr_window.c

    r4221 r4222  
    3131
    3232#include "actions.h"
     33#include "conf.h"
    3334#include "hig.h"
    3435#include "torrent-cell-renderer.h"
     36#include "tr_prefs.h"
    3537#include "tr_torrent.h"
    3638#include "tr_window.h"
     
    4648    GtkTreeSelection * selection;
    4749    GtkCellRenderer  * renderer;
     50    TrCore * core;
     51    gulong pref_handler_id;
    4852}
    4953PrivateData;
     
    121125}
    122126
     127static void
     128prefsChanged( TrCore * core UNUSED, const char * key, gpointer wind )
     129{
     130    if( !strcmp( key, PREF_KEY_MINIMAL_VIEW ) )
     131    {
     132       PrivateData * p = get_private_data( GTK_WINDOW( wind ) );
     133       g_object_set( p->renderer, "minimal", pref_flag_get( key ), NULL );
     134    }
     135}
     136
     137static void
     138privateFree( gpointer vprivate )
     139{
     140    PrivateData * p = (PrivateData*) vprivate;
     141    g_signal_handler_disconnect( p->core, p->pref_handler_id );
     142    g_free( p );
     143}
     144
    123145/***
    124146****  PUBLIC
     
    126148
    127149GtkWidget *
    128 tr_window_new( GtkUIManager * ui_manager )
     150tr_window_new( GtkUIManager * ui_manager, TrCore * core )
    129151{
    130152    PrivateData * p = g_new( PrivateData, 1 );
     
    133155    /* make the window */
    134156    self = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    135     g_object_set_data_full(G_OBJECT(self), PRIVATE_DATA_KEY, p, g_free );
     157    g_object_set_data_full(G_OBJECT(self), PRIVATE_DATA_KEY, p, privateFree );
    136158    gtk_window_set_title( GTK_WINDOW( self ), g_get_application_name());
    137159    gtk_window_set_role( GTK_WINDOW( self ), "tr-main" );
     
    177199    gtk_widget_show_all( vbox );
    178200
     201    /* listen for prefs changes that affect the window */
     202    prefsChanged( core, PREF_KEY_MINIMAL_VIEW, self );
     203    p->core = core;
     204    p->pref_handler_id = g_signal_connect( core, "prefs-changed", G_CALLBACK(prefsChanged), self );
     205
    179206    return self;
    180207}
  • trunk/gtk/tr_window.h

    r2149 r4222  
    2727
    2828#include <gtk/gtk.h>
     29#include "tr_core.h"
    2930
    3031typedef GtkWindow TrWindow;
     
    3233GtkTreeSelection * tr_window_get_selection( TrWindow* wind );
    3334
    34 GtkWidget * tr_window_new( GtkUIManager* );
     35GtkWidget * tr_window_new( GtkUIManager*, TrCore * core );
    3536
    36 void
    37 tr_window_update( TrWindow * wind, float downspeed, float upspeed );
     37void tr_window_update( TrWindow * wind, float downspeed, float upspeed );
    3838
    3939#endif
Note: See TracChangeset for help on using the changeset viewer.