Example #1
0
static void
maybeAddTorrent( TrCore * core, const char * filename )
{
    const gboolean isTorrent = g_str_has_suffix( filename, ".torrent" );

    if( isTorrent )
    {
        struct TrCorePrivate * p = core->priv;

        if( !g_slist_find_custom( p->monitor_files, filename, (GCompareFunc)compare_watchdir_file_to_filename ) )
            p->monitor_files = g_slist_append( p->monitor_files, watchdir_file_new( filename ) );

        if( !p->monitor_idle_tag )
            p->monitor_idle_tag = gtr_timeout_add_seconds( 1, watchFolderIdle, core );
    }
}
Example #2
0
static void
spun_cb( GtkSpinButton * w, gpointer core, gboolean isDouble )
{
    /* user may be spinning through many values, so let's hold off
       for a moment to keep from flooding the core with changes */
    GObject * o = G_OBJECT( w );
    struct spin_idle_data * data = g_object_get_data( o, IDLE_DATA );

    if( data == NULL )
    {
        data = g_new( struct spin_idle_data, 1 );
        data->core = core;
        data->last_change = g_timer_new( );
        data->isDouble = isDouble;
        g_object_set_data_full( o, IDLE_DATA, data, spin_idle_data_free );
        g_object_ref( G_OBJECT( o ) );
        gtr_timeout_add_seconds( 1, spun_cb_idle, w );
    }
Example #3
0
static void
onResponse( GtkDialog * dialog, int response, gpointer unused UNUSED )
{
    if( response == GTK_RESPONSE_APPLY )
    {
        GtkWidget * w;
        GObject * d = G_OBJECT( dialog );
        struct relocate_dialog_data * data = g_object_get_data( d, DATA_KEY );
        GtkFileChooser * chooser = g_object_get_data( d, "chooser" );
        GtkToggleButton * move_tb = g_object_get_data( d, "move_rb" );
        char * location = gtk_file_chooser_get_filename( chooser );

        data->do_move = gtk_toggle_button_get_active( move_tb );

        /* pop up a dialog saying that the work is in progress */
        w = gtk_message_dialog_new( GTK_WINDOW( dialog ),
                                    GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
                                    GTK_MESSAGE_INFO,
                                    GTK_BUTTONS_CLOSE,
                                    NULL );
        gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG( w ), _( "This may take a moment..." ) );
        gtk_dialog_set_response_sensitive( GTK_DIALOG( w ), GTK_RESPONSE_CLOSE, FALSE );
        gtk_widget_show( w );

        /* remember this location so that it can be the default next time */
        g_free( previousLocation );
        previousLocation = location;

        /* start the move and periodically check its status */
        data->message_dialog = w;
        data->done = TR_LOC_DONE;
        onTimer( data );
        gtr_timeout_add_seconds( 1, onTimer, data );
    }
    else
    {
        gtk_widget_destroy( GTK_WIDGET( dialog ) );
    }
}