Changeset 12400


Ignore:
Timestamp:
Apr 29, 2011, 9:36:44 PM (10 years ago)
Author:
jordan
Message:

(trunk gtk) in the details dialog, use the GQuark versions of g_object_{get,set}_data()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/details.c

    r12356 r12400  
    2929#include "util.h"
    3030
    31 #define DETAILS_KEY "details-data"
     31static GQuark ARG_KEY = 0;
     32static GQuark DETAILS_KEY = 0;
     33static GQuark TORRENT_ID_KEY = 0;
     34static GQuark TEXT_BUFFER_KEY = 0;
     35static GQuark URL_ENTRY_KEY = 0;
    3236
    3337struct DetailsImpl
     
    430434static void refresh( struct DetailsImpl * di );
    431435
    432 #define ARG_KEY "arg-key"
    433 
    434436static void
    435437onComboEnumChanged( GtkComboBox * combo_box, struct DetailsImpl * di )
    436438{
    437     const char * key = g_object_get_data( G_OBJECT( combo_box ), ARG_KEY );
     439    const char * key = g_object_get_qdata( G_OBJECT( combo_box ), ARG_KEY );
    438440    torrent_set_int( di, key, gtr_combo_box_get_active_enum( combo_box ) );
    439441    refresh( di );
     
    448450        _( "Stop seeding at ratio:" ),    TR_RATIOLIMIT_SINGLE,
    449451        NULL );
    450     g_object_set_data_full( G_OBJECT( w ), ARG_KEY, g_strdup( "seedRatioMode" ), g_free );
     452    g_object_set_qdata( G_OBJECT( w ), ARG_KEY, (gpointer)"seedRatioMode" );
    451453    return w;
    452454}
     
    460462        _( "Stop seeding if idle for N minutes:" ), TR_IDLELIMIT_SINGLE,
    461463        NULL );
    462     g_object_set_data_full( G_OBJECT( w ), ARG_KEY, g_strdup( "seedIdleMode" ), g_free );
     464    g_object_set_qdata( G_OBJECT( w ), ARG_KEY, (gpointer)"seedIdleMode" );
    463465    return w;
    464466}
     
    21122114        int tier;
    21132115        GtkTextIter start, end;
    2114         const int torrent_id = GPOINTER_TO_INT( g_object_get_data( G_OBJECT( dialog ), "torrent-id" ) );
    2115         GtkTextBuffer * text_buffer = g_object_get_data( G_OBJECT( dialog ), "text-buffer" );
     2116        const int torrent_id = GPOINTER_TO_INT( g_object_get_qdata( G_OBJECT( dialog ), TORRENT_ID_KEY ) );
     2117        GtkTextBuffer * text_buffer = g_object_get_qdata( G_OBJECT( dialog ), TEXT_BUFFER_KEY );
    21162118        tr_torrent * tor = gtr_core_find_torrent( di->core, torrent_id );
    21172119
     
    22372239        gtr_dialog_set_content( GTK_DIALOG( d ), t );
    22382240
    2239         g_object_set_data( G_OBJECT( d ), "torrent-id", GINT_TO_POINTER( torrent_id ) );
    2240         g_object_set_data( G_OBJECT( d ), "text-buffer", gtk_text_view_get_buffer( GTK_TEXT_VIEW( w ) ) );
     2241        g_object_set_qdata( G_OBJECT( d ), TORRENT_ID_KEY, GINT_TO_POINTER( torrent_id ) );
     2242        g_object_set_qdata( G_OBJECT( d ), TEXT_BUFFER_KEY, gtk_text_view_get_buffer( GTK_TEXT_VIEW( w ) ) );
    22412243        gtk_widget_show( d );
    22422244    }
     
    22632265    {
    22642266        struct DetailsImpl * di = gdi;
    2265         GtkWidget * e = GTK_WIDGET( g_object_get_data( G_OBJECT( dialog ), "url-entry" ) );
    2266         const int torrent_id = GPOINTER_TO_INT( g_object_get_data( G_OBJECT( dialog ), "torrent-id" ) );
     2267        GtkWidget * e = GTK_WIDGET( g_object_get_qdata( G_OBJECT( dialog ), URL_ENTRY_KEY ) );
     2268        const int torrent_id = GPOINTER_TO_INT( g_object_get_qdata( G_OBJECT( dialog ), TORRENT_ID_KEY ) );
    22672269        char * url = g_strdup( gtk_entry_get_text( GTK_ENTRY( e ) ) );
    22682270        g_strstrip( url );
     
    23292331        gtk_widget_set_size_request( e, 400, -1 );
    23302332        gtr_paste_clipboard_url_into_entry( e );
    2331         g_object_set_data( G_OBJECT( w ), "url-entry", e );
    2332         g_object_set_data( G_OBJECT( w ), "torrent-id", GINT_TO_POINTER( tr_torrentId( tor ) ) );
     2333        g_object_set_qdata( G_OBJECT( w ), URL_ENTRY_KEY, e );
     2334        g_object_set_qdata( G_OBJECT( w ), TORRENT_ID_KEY, GINT_TO_POINTER( tr_torrentId( tor ) ) );
    23332335        hig_workarea_add_row( t, &row, _( "_Announce URL:" ), e, NULL );
    23342336        gtr_dialog_set_content( GTK_DIALOG( w ), t );
     
    25152517    struct DetailsImpl * di = g_new0( struct DetailsImpl, 1 );
    25162518
     2519    /* one-time setup */
     2520    if( ARG_KEY == 0 )
     2521    {
     2522        ARG_KEY          = g_quark_from_static_string( "tr-arg-key" );
     2523        DETAILS_KEY      = g_quark_from_static_string( "tr-details-data-key" );
     2524        TORRENT_ID_KEY   = g_quark_from_static_string( "tr-torrent-id-key" );
     2525        TEXT_BUFFER_KEY  = g_quark_from_static_string( "tr-text-buffer-key" );
     2526        URL_ENTRY_KEY    = g_quark_from_static_string( "tr-url-entry-key" );
     2527    }
     2528
    25172529    /* create the dialog */
    25182530    di->core = core;
     
    25262538                              G_CALLBACK( gtk_widget_destroy ), d );
    25272539    gtk_container_set_border_width( GTK_CONTAINER( d ), GUI_PAD );
    2528     g_object_set_data_full( G_OBJECT( d ), DETAILS_KEY, di, details_free );
     2540    g_object_set_qdata_full( G_OBJECT( d ), DETAILS_KEY, di, details_free );
    25292541
    25302542    n = gtk_notebook_new( );
     
    25672579    char title[256];
    25682580    const int len = g_slist_length( ids );
    2569     struct DetailsImpl * di = g_object_get_data( G_OBJECT( w ), DETAILS_KEY );
     2581    struct DetailsImpl * di = g_object_get_qdata( G_OBJECT( w ), DETAILS_KEY );
    25702582
    25712583    g_slist_free( di->ids );
Note: See TracChangeset for help on using the changeset viewer.