Changeset 12318


Ignore:
Timestamp:
Apr 5, 2011, 4:16:06 PM (11 years ago)
Author:
jordan
Message:

(trunk gtk) use GQuarks instead of strings for keys in tr-icon and tr-window

Location:
trunk/gtk
Files:
2 edited

Legend:

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

    r12090 r12318  
    2121#include "tr-icon.h"
    2222#include "util.h"
     23
     24static GQuark
     25get_core_quark( void )
     26{
     27    static GQuark quark = 0;
     28    if( !quark ) quark = g_quark_from_static_string( "tr-core" );
     29    return quark;
     30}
    2331
    2432#define ICON_NAME "transmission"
     
    6674    const char * idle = _( "Idle" );
    6775    GtkStatusIcon * icon = GTK_STATUS_ICON( vicon );
    68     tr_session * session = gtr_core_session( g_object_get_data( G_OBJECT( icon ), "tr-core" ) );
     76    tr_session * session = gtr_core_session( g_object_get_qdata( G_OBJECT( icon ), get_core_quark( ) ) );
    6977
    7078    /* up */
     
    145153    w = gtr_action_get_widget( "/icon-popup" );
    146154    app_indicator_set_menu( indicator, GTK_MENU ( w ) );
    147     g_object_set_data( G_OBJECT( indicator ), "tr-core", core );
     155    g_object_set_qdata( G_OBJECT( indicator ), get_core_quark( ), core );
    148156    return indicator;
    149157}
     
    156164    g_signal_connect( icon, "activate", G_CALLBACK( activated ), NULL );
    157165    g_signal_connect( icon, "popup-menu", G_CALLBACK( popup ), NULL );
    158     g_object_set_data( G_OBJECT( icon ), "tr-core", core );
     166    g_object_set_qdata( G_OBJECT( icon ), get_core_quark( ), core );
    159167    return icon;
    160168}
  • trunk/gtk/tr-window.c

    r12234 r12318  
    8080PrivateData;
    8181
    82 #define PRIVATE_DATA_KEY "private-data"
     82static GQuark
     83get_private_data_key( void )
     84{
     85    static GQuark q = 0;
     86    if( !q ) q = g_quark_from_static_string( "private-data" );
     87    return q;
     88}
    8389
    8490static PrivateData*
    8591get_private_data( TrWindow * w )
    8692{
    87     return g_object_get_data ( G_OBJECT( w ), PRIVATE_DATA_KEY );
     93    return g_object_get_qdata ( G_OBJECT( w ), get_private_data_key( ) );
    8894}
    8995
     
    580586    /* make the window */
    581587    self = gtk_window_new ( GTK_WINDOW_TOPLEVEL );
    582     g_object_set_data_full( G_OBJECT(
    583                                 self ), PRIVATE_DATA_KEY, p, privateFree );
     588    g_object_set_qdata_full( G_OBJECT(self), get_private_data_key( ), p, privateFree );
    584589    win = GTK_WINDOW( self );
    585590    gtk_window_set_title( win, g_get_application_name( ) );
Note: See TracChangeset for help on using the changeset viewer.